-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Closed as not planned
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
With locale "fr_CH.UTF-8", the thousand separator is (possibly) wrong. It should be a plain apostrophe (U+0027) or a hard space (U+00A0 I guess), not a modifier letter apostrophe (U+02BC, or whatever it is -- looks weird) -- cf, page 35 of the official style guide.
Example (with workaround) -- numbers from a financial CSV sheet issued by UBS Switzerland:
py>> import locale
py>> locale.setlocale(locale.LC_NUMERIC, 'fr_CH.utf8')
'fr_CH.utf8'
py>> locale.localeconv()["thousands_sep"]
'’'
py>> locale.atof("1'080.10")
Traceback (most recent call last):
File "<python-input-3>", line 1, in <module>
locale.atof("1'080.10")
~~~~~~~~~~~^^^^^^^^^^^^
File "/usr/lib/python3.14/locale.py", line 328, in atof
return func(delocalize(string))
ValueError: could not convert string to float: "1'080.10"
py>> locale._override_localeconv={"thousands_sep":"'"}
py>> locale.atof("1'080.10")
1080.1Ideally, both separator options should be supported, though that might make for another bug report. Let me know.
Tested with Python-3.13 and Python-3.14.
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Done