-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
bpo-31900: Fix localeconv() encoding for LC_NUMERIC #4174
Conversation
Tested the PR on a system with glibc 2.26.90 where the test was failing, and it successfully passed. |
Ping myself. |
I rebased my changed, fixed a bug in error handler (restore the LC_CTYPE if RESULT fails), and added documentation. |
I completed my change to also fix str.format():
|
I completed my change to also fix decimal.Decimal. |
@vstinner Cool, but could you make the decimal part a separate PR? |
Would you mind to elaborate? Why should it be fixed in a different PR? |
On Wed, Jan 10, 2018 at 09:13:57AM -0800, Victor Stinner wrote:
Would you mind to elaborate? Why should it be fixed in a different PR?
Because we both thought that this issue was not very important a couple
of years ago and I want to look at it and run my own tests.
|
Well, something changed in the meanwhile, the glibc: https://bugs.python.org/issue31900#msg305227 Anyway, I reverted changes on the decimal module. |
* Add _Py_GetLocaleconvNumeric() function: decode decimal_point and thousands_sep fields of localeconv() from the LC_NUMERIC encoding, rather than decoding from the LC_CTYPE encoding. * Modify locale.localeconv() and "n" formatter of str.format() (for int, float and complex to use _Py_GetLocaleconvNumeric() internally.
Ah, moreover I avoided the setlocale() if LC_NUMERIC = LC_CTYPE. |
The setlocale() is only done in a rare use case (LC_NUMERIC and LC_CTYPE have a different encoding), it's safe to call localeconv() in all other cases.
) * Add _Py_GetLocaleconvNumeric() function: decode decimal_point and thousands_sep fields of localeconv() from the LC_NUMERIC encoding, rather than decoding from the LC_CTYPE encoding. * Modify locale.localeconv() and "n" formatter of str.format() (for int, float and complex to use _Py_GetLocaleconvNumeric() internally. (cherry picked from commit cb064fc)
Decode localeconv() numeric fields like thousands_sep from the
LC_NUMERIC encoding, rather than decoding from the LC_CTYPE encoding.
https://bugs.python.org/issue31900