-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Recording and restoring the LC_NUMERIC locale setting with LC_ALL=C.UTF-8 no longer works with Python 3.13.3 #133967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm at the CPython sprints right now, so I can take a look at this. |
While I'm unable to reproduce your exact issue, I'm debugging a slightly similar issue that I'm having on my machine. Instead of the error, I'm getting this: Type "help", "copyright", "credits" or "license" for more information.
>>> import os, locale
>>> os.environ
environ({'PATH': '/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'HOSTNAME': '64800af765e4', 'TERM': 'xterm', 'GPG_KEY': '7169605F62C751356D054A26A821E680E5FA6305', 'PYTHON_VERSION': '3.13.2', 'PYTHON_SHA256': 'd984bcc57cd67caab26f7def42e523b1c015bbc5dc07836cf4f0b63fa159eb56', 'HOME': '/root', 'LC_CTYPE': 'C.UTF-8'})
>>> os.environ["LC_ALL"] = "C.UTF-8"
>>> locale.setlocale(locale.LC_ALL, "")
'C.UTF-8'
>>> locale.getlocale(locale.LC_NUMERIC)
('en_US, UTF-8)
>>> locale.setlocale(locale.LC_NUMERIC, ('C', 'UTF-8'))
'en_US.UTF-8' |
Thank you for taking the time to investigate! Are you using the Python containers from Dockerhub? In my tests with those containers, the problem only appears with Python 3.13.3, while for you, it seems to partially appear in 3.13.2, but without the crash when trying to set |
Ah, this is for 3.13.3! |
many thanks @mvkashyap 🍺 |
This was caused by #129646. The cc @malemburg |
I think the problem is different: the In any case, we should probably special case the |
BTW: I do wonder why the locale files don't exist in the official Python docker image. Note that This suggests that the official images are somewhat broken... where can this be reported ? |
Checking using |
This is what I came to. It is not clear what to do with the |
…-8' (pythonGH-135347) (cherry picked from commit 0f866cb) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…-8' (pythonGH-135347) (cherry picked from commit 0f866cb) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Let's leave that as it is, since it hasn't caused any reported issues, AFAIK. |
en_US.ISO8859-1 is much more likely to exist. It still makes me very uncomfortable (as mentioned on Discord) because we're changing the encoding in a patch release, but it's not entirely clear to me when and how this could affect people. |
For some people changing the encoding was a bug fix, for others a regression. This is a problem with such approach -- there may be different default encodings for the same locale on different platforms, but the locale module will use the same mapping. There are even conflicts between glibc and X.org mappings, so this problem is not Python specific. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
We have project where we record the current value of
locale.LC_NUMERIC
, change it to a different value to use a library that needs a particular locale setting, and then restore it to the original value. This stopped working with Python 3.13.3. I suspect this may be a bug, but please correct me if I misunderstood the functionality.Example with Python 3.13.3:
The same example works fine with earlier versions of Python, for example 3.13.2:
It looks like this may have been caused by the changes in #129647.
CPython versions tested on:
3.13
Operating systems tested on:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: