Merge pull request #4779 from thomashk0/fix-win-lcmessages

Handle missing LC_MESSAGES attribute on Windows
This commit is contained in:
Takeshi KOMIYA 2018-03-26 01:23:00 +09:00 committed by GitHub
commit 5734d8ad02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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')