You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cf_units fails to import when the LC_NUMERIC environmental variable is set to a locale that has a , instead of a . as the decimal_point character and Python sets the locale. This typically happens in documentation builds with sphinx. See pydata/xarray#4257 for an example. I have encountered the same issue when building the iris and ESMValCore documentation.
Traceback (most recent call last):
File "/home/bandela/src/scitools/cf_units/cf_units/__init__.py", line 187, in <module>
_ud_system = _ud.read_xml()
^^^^^^^^^^^^^^
File "cf_units/_udunits2.pyx", line 194, in cf_units._udunits2.read_xml
return wrap_system(csystem)
File "cf_units/_udunits2.pyx", line 104, in cf_units._udunits2.wrap_system
_raise_error()
File "cf_units/_udunits2.pyx", line 184, in cf_units._udunits2._raise_error
raise UdunitsError(status, errnum)
cf_units._udunits2.UdunitsError: UT_PARSE
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/bandela/src/scitools/cf_units/cf_units/__init__.py", line 190, in <module>
_ud_system = _ud.read_xml(config.get_xml_path())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "cf_units/_udunits2.pyx", line 194, in cf_units._udunits2.read_xml
return wrap_system(csystem)
File "cf_units/_udunits2.pyx", line 104, in cf_units._udunits2.wrap_system
_raise_error()
File "cf_units/_udunits2.pyx", line 184, in cf_units._udunits2._raise_error
raise UdunitsError(status, errnum)
cf_units._udunits2.UdunitsError: UT_PARSE
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/bandela/src/scitools/cf_units/test.py", line 4, in <module>
import cf_units
File "/home/bandela/src/scitools/cf_units/cf_units/__init__.py", line 193, in <module>
raise OSError(
OSError: [UT_PARSE] Failed to open UDUNITS-2 XML unit database
Expected Behaviour
A successful import.
Environment
OS & Version: Ubuntu 24.04 LTS
cf-units Version: 3.2.1.dev57
Additional Context
When I comment out the suppress_warnings context manager here
🐛 Bug Report
cf_units
fails to import when theLC_NUMERIC
environmental variable is set to a locale that has a,
instead of a.
as thedecimal_point
character and Python sets the locale. This typically happens in documentation builds with sphinx. See pydata/xarray#4257 for an example. I have encountered the same issue when building the iris and ESMValCore documentation.How to Reproduce
Steps to reproduce the behaviour:
export LC_NUMERIC=nl_NL.UTF-8
locale
:Run the following Python code to set the locale
Expected Behaviour
A successful import.
Environment
Additional Context
When I comment out the
suppress_warnings
context manager herecf-units/cf_units/__init__.py
Line 182 in f57a7f1
I see the following error message:
some searching trough the udunits2 code suggests that it originates from using the
strtod
function in this code, which uses thedecimal-point
locale setting.The text was updated successfully, but these errors were encountered: