This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, lemburg, serhiy.storchaka, vstinner
Date 2022-02-08.10:10:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1644315009.26.0.639903835602.issue46659@roundup.psfhosted.org>
In-reply-to
Content
> getdefaultlocale() falls back to LANG and LANGUAGE.

_Py_SetLocaleFromEnv(LC_CTYPE) (e.g. setlocale(LC_CTYPE, "")) gets called at startup, except for the isolated configuration [1].

I think calendar.Locale*Calendar should try the LC_CTYPE locale if LC_TIME is "C", i.e. (None, None). Otherwise, it's introducing new default behavior. For example, with LC_ALL set to "ru_RU.utf8":

3.8:

    >>> locale.getlocale(locale.LC_TIME)
    (None, None)
    >>> locale.getlocale(locale.LC_CTYPE)
    ('ru_RU', 'UTF-8')
    >>> cal = calendar.LocaleTextCalendar()
    >>> cal.formatweekday(0, 15)
    '  Понедельник  '

3.11.0a5+:

    >>> locale.getlocale(locale.LC_TIME)
    (None, None)
    >>> locale.getlocale(locale.LC_CTYPE)
    ('ru_RU', 'UTF-8')
    >>> cal = calendar.LocaleTextCalendar()
    >>> cal.formatweekday(0, 15)
    '     Monday    '
    >>> locale.setlocale(locale.LC_TIME, '')
    'ru_RU.utf8'
    >>> cal = calendar.LocaleTextCalendar()
    >>> cal.formatweekday(0, 15)
    '  Понедельник  '

---

[1] https://docs.python.org/3/c-api/init_config.html?#isolated-configuration
History
Date User Action Args
2022-02-08 10:10:09eryksunsetrecipients: + eryksun, lemburg, vstinner, serhiy.storchaka
2022-02-08 10:10:09eryksunsetmessageid: <1644315009.26.0.639903835602.issue46659@roundup.psfhosted.org>
2022-02-08 10:10:09eryksunlinkissue46659 messages
2022-02-08 10:10:09eryksuncreate