bpo-35697, decimal: Fix locale formatting#11474
Closed
vstinner wants to merge 3 commits intopython:masterfrom
vstinner:decimal_locale
Closed
bpo-35697, decimal: Fix locale formatting#11474vstinner wants to merge 3 commits intopython:masterfrom vstinner:decimal_locale
vstinner wants to merge 3 commits intopython:masterfrom
vstinner:decimal_locale
Conversation
The decimal module now supports formatting number to the "n" type when the LC_NUMERIC locale uses a different encoding than the LC_CTYPE locale. It now sets temporarily the LC_CTYPE locale to the LC_NUMERIC locale to decode decimal_point and thousands_sep byte strings if they are non-ASCII or longer than 1 byte, and the LC_NUMERIC locale is different than the LC_CTYPE locale. This temporary change affects other threads. Fix also #define guard of pycore_fileutils.h: allow also Py_BUILD_CORE_BUILTIN.
Member
Author
|
This PR is based on my previous attempt: PR #5191 that I abandoned. I'm not sure of the implementation of this change. It's a little bit weird that mpd_parse_fmt_str() calls localeconv() to get the decimal point and thousands separator, but then dec_format() calls again localeconv(). I chose this implementation to restrict changes in libmpdec. |
Member
Author
|
Oh, I forgot to update the Windows VS project: |
Member
Author
|
I'm no longer interested to rewrite my patch to avoid _Py_GetLocaleconvNumeric() which comes from the internal API, so I close my PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The decimal module now supports formatting number to the "n" type
when the LC_NUMERIC locale uses a different encoding than the
LC_CTYPE locale. It now sets temporarily the LC_CTYPE locale to the
LC_NUMERIC locale to decode decimal_point and thousands_sep byte
strings if they are non-ASCII or longer than 1 byte, and the
LC_NUMERIC locale is different than the LC_CTYPE locale. This
temporary change affects other threads.
Fix also #define guard of pycore_fileutils.h: allow also
Py_BUILD_CORE_BUILTIN.
https://bugs.python.org/issue35697