From 2d9e7f9baafc5426e5d8efb41121b74e9ec9db6e Mon Sep 17 00:00:00 2001 From: Thomas Hiscock Date: Sun, 25 Mar 2018 10:56:46 +0200 Subject: [PATCH] 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). --- sphinx/locale/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py index b0bf0ead1..b17da28e9 100644 --- a/sphinx/locale/__init__.py +++ b/sphinx/locale/__init__.py @@ -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')