[issue46735] gettext.translations crashes when locale is unset

Terry J. Reedy report at bugs.python.org
Fri Feb 18 15:13:14 EST 2022


Terry J. Reedy <tjreedy at udel.edu> added the comment:

As 'crash', as used here, is when python exits abnormally *without* an exception traceback.  The traceback in the linked report is:

Traceback (most recent call last):
  File "video2x.py", line 53, in <module>
    from upscaler import AVAILABLE_DRIVERS
  File "/home/meltonmb/video2x-4.6.1/src/upscaler.py", line 48, in <module>
    language = gettext.translation(DOMAIN, LOCALE_DIRECTORY, [default_locale], fallback=True)
  File "/usr/lib/python3.8/gettext.py", line 583, in translation
    mofiles = find(domain, localedir, languages, all=True)
  File "/usr/lib/python3.8/gettext.py", line 554, in find
    for nelang in _expand_lang(lang):
  File "/usr/lib/python3.8/gettext.py", line 213, in _expand_lang
    loc = locale.normalize(loc)
  File "/usr/lib/python3.8/locale.py", line 401, in normalize
    code = localename.lower()
AttributeError: 'NoneType' object has no attribute 'lower'

Whether the bug is in the 3rd party module 'upscaler' or the stdlib module gettext depends on whether the DOMAIN, LOCALE_DIRECTORY, and [default_locale] arguments in upscaler's call to gettext.translation meet the documented requirements.  What are their values?

----------
nosy: +terry.reedy

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46735>
_______________________________________


More information about the Python-bugs-list mailing list