Skip to content

Commit 899c7dc

Browse files
gh-133740: Fix locale.nl_langinfo(ALT_DIGITS) (#134468)
Set the LC_CTYPE locale to the LC_TIME locale even if nl_langinfo(ALT_DIGITS) result is ASCII. The result is a list separated by NUL characters and the code only checks the first list item which can be ASCII whereas following items are non-ASCII. Fix test__locale for the uk_UA locale on RHEL 7. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 8c5e555 commit 899c7dc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Modules/_localemodule.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,17 @@ _locale_nl_langinfo_impl(PyObject *module, int item)
692692
result = result != NULL ? result : "";
693693
char *oldloc = NULL;
694694
if (langinfo_constants[i].category != LC_CTYPE
695-
&& !is_all_ascii(result)
695+
&& (
696+
#ifdef __GLIBC__
697+
// gh-133740: Always change the locale for ALT_DIGITS and ERA
698+
# ifdef ALT_DIGITS
699+
item == ALT_DIGITS ||
700+
# endif
701+
# ifdef ERA
702+
item == ERA ||
703+
# endif
704+
#endif
705+
!is_all_ascii(result))
696706
&& change_locale(langinfo_constants[i].category, &oldloc) < 0)
697707
{
698708
return NULL;

0 commit comments

Comments
 (0)