locale.nl_langinfo(locale.ERA) is broken · Issue #125411 · python/cpython · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

locale.nl_langinfo(locale.ERA) is broken #125411

Open
@serhiy-storchaka

Description

@serhiy-storchaka

Bug report

It is broken in the same way as locale.nl_langinfo(locale.ALT_DIGITS) was broken (see #124969), although not to the same degree. It returns the last (current) era.

import locale, subprocess
alllocales = subprocess.check_output(['locale', '-a']).decode().split()
for loc in alllocales:
    if '.' in loc or '@' in loc:
        continue
    try:
        _ = locale.setlocale(locale.LC_ALL, loc)
    except locale.Error:
        continue
    era = locale.nl_langinfo(locale.ERA)
    if era:
        print(loc, era)

Output:

cmn_TW +:2:1913/01/01:+*:民國:%EC%Ey年
hak_TW +:2:1913/01/01:+*:民國:%EC%Ey年
ja_JP +:2:2020/01/01:+*:令和:%EC%Ey年
japanese +:2:2020/01/01:+*:令和:%EC%Ey年
lo_LA +:1:-543/01/01:+*:ພ.ສ.:%EC %Ey
lzh_TW +:2:1913/01/01:+*:民國:%EC%Ey年
nan_TW +:2:1913/01/01:+*:民國:%EC%Ey年
thai +:1:-543/01/01:+*:พ.ศ.:%EC %Ey
th_TH +:1:-543/01/01:+*:พ.ศ.:%EC %Ey
zh_TW +:2:1913/01/01:+*:民國:%EC%Ey年

The result is not completely useless, as it can be used to format and parse the current dates. But dates before the start of the current era (it is 2020 in Japan) cannot be proceeded.

The result should be a tuple, containing information for all eras, but this is a breaking change. So, perhaps such change cannot be backported.

cc @methane

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixes3.15new features, bugs and security fixesextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      TMZ Celebrity News – Breaking Stories, Videos & Gossip

      Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

      Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

      🎥 Watch TMZ Live

      TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.