Description
ALT_DIGITS is a glibc specific item. It is supported by Python (there is an explicit list of supported items), but the result is not correct.
From The GNU C Library Reference Manual:
ALT_DIGITS
The return value is a representation of up to 100 values used to represent the values 0 to 99. As for ERA this value is not intended to be used directly, but instead indirectly through the strftime function. When the modifier O is used in a format which would otherwise use numerals to represent hours, minutes, seconds, weekdays, months, or weeks, the appropriate value for the locale is used instead.
This value is only defined in few locales: az_IR, fa_IR, ja_JP, lzh_TW, my_MM, or_IN, shn_MM.
But Python returns only one digit.
>>> import locale
>>> locale.setlocale(locale.LC_TIME, 'ja_JP')
'ja_JP'
>>> locale.setlocale(locale.LC_CTYPE, 'ja_JP')
'ja_JP'
>>> locale.nl_langinfo(locale.ALT_DIGITS)
'〇'
This is because nl_langinfo(ALT_DIGITS)
in C returns a string with embedded null characters.
How should we fix it?
- return a single string with 99 embedded null characters
- return a 100-tuple of strings
What should we return if the value is not defined (in most locales) -- empty string (current behavior), empty tuple or None?
cc @methane
Linked PRs
- gh-124969: Fix locale.nl_langinfo(locale.ALT_DIGITS) #124974
- gh-124969: Skip the test for ALT_DIGITS also on iOS #125177
- [3.13] gh-124969: Fix locale.nl_langinfo(locale.ALT_DIGITS) (GH-124974) #125232
- [3.12] [3.13] gh-124969: Fix locale.nl_langinfo(locale.ALT_DIGITS) (GH-124974) (GH-125232) #125284
- gh-124969: Make locale.nl_langinfo(locale.ALT_DIGITS) returning a string again #125774
- [3.13] gh-124969: Make locale.nl_langinfo(locale.ALT_DIGITS) returning a string again (GH-125774) #125804
- [3.12] gh-124969: Make locale.nl_langinfo(locale.ALT_DIGITS) returning a string again (GH-125774) #125805
Metadata
Metadata
Assignees
Projects
Status