Repository navigation
test_alt_digits_nl_langinfo fails for locale uk_UA #133740
Copy link
Copy link
Closed
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
test_alt_digits_nl_langinfo (test.test__locale._LocaleTests.test_alt_digits_nl_langinfo) ...
test_alt_digits_nl_langinfo (test.test__locale._LocaleTests.test_alt_digits_nl_langinfo) (locale='sr_YU') ... skipped "no locale 'sr_YU'"
test_alt_digits_nl_langinfo (test.test__locale._LocaleTests.test_alt_digits_nl_langinfo) (locale='uk_UA') ... ERROR
test_alt_digits_nl_langinfo (test.test__locale._LocaleTests.test_alt_digits_nl_langinfo) (locale='lzh_TW.UTF-8') ... skipped "no locale 'lzh_TW.UTF-8'"
test_alt_digits_nl_langinfo (test.test__locale._LocaleTests.test_alt_digits_nl_langinfo) (locale='shn_MM.UTF-8') ... skipped "no locale 'shn_MM.UTF-8'"
test_alt_digits_nl_langinfo (test.test__locale._LocaleTests.test_alt_digits_nl_langinfo) (locale='ar_AE.UTF-8') ... skipped "ALT_DIGITS is not set for locale 'ar_AE.UTF-8' on this platform"
test_alt_digits_nl_langinfo (test.test__locale._LocaleTests.test_alt_digits_nl_langinfo) (locale='bn_IN.UTF-8') ... skipped "ALT_DIGITS is not set for locale 'bn_IN.UTF-8' on this platform"
test_era_nl_langinfo (test.test__locale._LocaleTests.test_era_nl_langinfo) ...
test_era_nl_langinfo (test.test__locale._LocaleTests.test_era_nl_langinfo) (locale='sr_YU') ... skipped "no locale 'sr_YU'"
test_era_nl_langinfo (test.test__locale._LocaleTests.test_era_nl_langinfo) (locale='lzh_TW.UTF-8') ... skipped "no locale 'lzh_TW.UTF-8'"
test_era_nl_langinfo (test.test__locale._LocaleTests.test_era_nl_langinfo) (locale='shn_MM.UTF-8') ... skipped "no locale 'shn_MM.UTF-8'"
test_float_parsing (test.test__locale._LocaleTests.test_float_parsing) ... ok
test_lc_numeric_basic (test.test__locale._LocaleTests.test_lc_numeric_basic) ... ok
test_lc_numeric_localeconv (test.test__locale._LocaleTests.test_lc_numeric_localeconv) ... ok
test_lc_numeric_nl_langinfo (test.test__locale._LocaleTests.test_lc_numeric_nl_langinfo) ... ok
======================================================================
ERROR: test_alt_digits_nl_langinfo (test.test__locale._LocaleTests.test_alt_digits_nl_langinfo) (locale='uk_UA')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/bb/data/tmp/314/refroot/amd64/opt/bb/lib64/python3.14/test/test__locale.py", line 220, in test_alt_digits_nl_langinfo
alt_digits = nl_langinfo(locale.ALT_DIGITS)
UnicodeDecodeError: 'locale' codec can't decode byte 0xde in position 4: decoding error
----------------------------------------------------------------------
Ran 6 tests in 0.012sThis is in a Red Hat Enterprise Linux Server release 7.6 (Maipo) machine
CPython versions tested on:
CPython main branch, 3.14
Operating systems tested on:
Linux
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
- StatusShow more project fieldsDone
Activity
pablogsal commentedon May 9, 2025
CC @vstinner @serhiy-storchaka
serhiy-storchaka commentedon May 9, 2025
This is weird. ALT_DIGITS should be empty for uk_UA, as for most locales. Most likely this is a platform bug.
How old is RHELS 7.6? Is it new or ancient? Does the test pass on other versions? What version of libc?
pablogsal commentedon May 9, 2025
Sort of ancient (from 2014) :)
This is the version of glib:
pablogsal commentedon May 9, 2025
Interestingly when I test with this:
I get:
ALT_DIGITS for uk_UA: 0
pablogsal commentedon May 9, 2025
Also tried this:
This prints:
and with this:
prints
pablogsal commentedon May 9, 2025
Some investigation with gdb:
pablogsal commentedon May 9, 2025
Looks like this is the problem:
vstinner commentedon May 9, 2025
Related changes:
vstinner commentedon May 9, 2025
You should look further in the string since glibc uses NUL separator in ALT_DIGITS value.
pablogsal commentedon May 9, 2025
Yeah but that's the problem I think: we are passing the 0 directly to decode string, no? Or who you mean by "you" here?
serhiy-storchaka commentedon May 9, 2025
There was a hack that used ALT_DIGITS for month names in a genitive case. It was removed in https://sourceware.org/git/?p=glibc.git;a=commit;h=86530b9fed4466a7c05e20ec4d5fd89b4dc41fa6 .
Glibc uses null separator instead of ";" for ALT_DIGITS (in violation of Posix). This is why you get "0". Python has a work around this, so it sees the whole thing, including non-ASCII month names.
Binary locale files for the "uk_UA" locale are created using the "KOI8-U" encoding, as specified in
localedata/SUPPORTED. But it seems that UTF-8 was used for decoding. Could you please print the results ofsetlocale(LC_CTYPE, NULL)andsetlocale(LC_TIME, NULL)? And the result ofnl_langinfo(CODESET)after callingsetlocale(LC_CTYPE, setlocale(LC_TIME, NULL))?21 remaining items
serhiy-storchaka commentedon Jul 3, 2025
There was a small regression -- there is no need to switch locale if the result is empty.
pythongh-133740: Fix regression in locale.nl_langinfo(ALT_DIGITS)
gh-133740: Fix regression in locale.nl_langinfo(ALT_DIGITS) (GH-136237)
pythongh-133740: Fix regression in locale.nl_langinfo(ALT_DIGITS) (py…
[3.14] gh-133740: Fix regression in locale.nl_langinfo(ALT_DIGITS) (G…
pythongh-133740: Fix regression in locale.nl_langinfo(ALT_DIGITS) (py…
pythongh-133740: Fix locale.nl_langinfo(ALT_DIGITS) (python#134468)
pythongh-133740: Fix regression in locale.nl_langinfo(ALT_DIGITS) (py…
pythongh-133740: Fix regression in locale.nl_langinfo(ALT_DIGITS) (py…
pythongh-133740: Fix locale.nl_langinfo(ALT_DIGITS) (python#134468)
pythongh-133740: Fix regression in locale.nl_langinfo(ALT_DIGITS) (py…
pythongh-133740: Fix regression in locale.nl_langinfo(ALT_DIGITS) (py…
pythongh-133740: Fix locale.nl_langinfo(ALT_DIGITS) (python#134468)