You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
locale.nl_langinfo(locale.ERA) does not work for past eras #126727
According to the Posix specification (https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap07.html#tag_07_03_05_02), nl_langinfo(ERA) should return a string containing semicolon separated era description segments. But in Glibc it uses NUL instead of a semicolon as a separator. As result, locale.nl_langinfo(locale.ERA) in Python only returns the first segment, corresponding to the last (current) era. For example, in Japanese locale the result cannot be used for data before year 2020:
Activity
pythongh-126727: Fix locale.nl_langinfo(locale.ERA)
serhiy-storchaka commentedon Nov 12, 2024
On my computer (Linux) the following script
now produces the following output:
The ERA values are not set on FreeBSD and Illumos, and I suppose on macOS and Solaris too. It seems that currently they are only set on Linux.
gh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730)
[3.13] pythongh-126727: Fix locale.nl_langinfo(locale.ERA) (pythonGH-…
[3.12] pythongh-126727: Fix locale.nl_langinfo(locale.ERA) (pythonGH-…
[3.12] gh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730) (GH-…
[3.13] gh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730) (GH-…
kulikjak commentedon Nov 27, 2024
Hi @serhiy-storchaka, I am sorry I couldn't test this earlier.
While they are indeed not set on Illumos, we have them on Oracle Solaris for some locales:
Unfortunately, we have fewer Japanese ERAs than Linux (which causes the newly added test to fail), but I created #127327 to handle this.
GH-126727: Fix test_era_nl_langinfo with Japanese ERAs on Solaris (GH…
pythonGH-126727: Fix test_era_nl_langinfo with Japanese ERAs on Solar…
pythonGH-126727: Fix test_era_nl_langinfo with Japanese ERAs on Solar…
serhiy-storchaka commentedon Dec 5, 2024
Thank you @kulikjak.
[3.12] GH-126727: Fix test_era_nl_langinfo with Japanese ERAs on Sola…
[3.13] GH-126727: Fix test_era_nl_langinfo with Japanese ERAs on Sola…
pythonGH-126727: Fix test_era_nl_langinfo with Japanese ERAs on Solar…
pythongh-126727: Fix locale.nl_langinfo(locale.ERA) (pythonGH-126730)