Skip to content

locale: wrong thousand separator for "fr_CH.UTF-8" #141631

@sphakka

Description

@sphakka

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.1

Ideally, 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

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions