Eryk Sun <eryk...@gmail.com> added the comment:

> 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

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46659>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to