Handle missing LC_MESSAGES attribute on Windows

This small fix handles the case where LC_MESSAGES is not defined
in Python's locale module (e.g., on Windows).
This commit is contained in:
Thomas Hiscock 2018-03-25 10:56:46 +02:00
parent 69383f83bd
commit 2d9e7f9baa

View File

@ -253,7 +253,13 @@ def init_console(locale_dir, catalog):
.. versionadded:: 1.8
"""
language, _ = locale.getlocale(locale.LC_MESSAGES) # encoding is ignored
try:
# encoding is ignored
language, _ = locale.getlocale(locale.LC_MESSAGES)
except AttributeError:
# LC_MESSAGES is not always defined. Fallback to the default language
# in case it is not.
language = None
return init([locale_dir], language, catalog, 'console')