mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #5724: quickstart: sphinx-quickstart fails when $LC_ALL is empty
This commit is contained in:
parent
e9c87b3d13
commit
4b331dae48
1
CHANGES
1
CHANGES
@ -26,6 +26,7 @@ Bugs fixed
|
||||
(refs: #1238)
|
||||
* #5636: C++, fix parsing of floating point literals.
|
||||
* #5496 (again): C++, fix assertion in partial builds with duplicates.
|
||||
* #5724: quickstart: sphinx-quickstart fails when $LC_ALL is empty
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -310,7 +310,7 @@ def build_main(argv=sys.argv[1:]): # type: ignore
|
||||
|
||||
def main(argv=sys.argv[1:]): # type: ignore
|
||||
# type: (List[unicode]) -> int
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.init_console(os.path.join(package_dir, 'locale'), 'sphinx')
|
||||
|
||||
if argv[:1] == ['-M']:
|
||||
|
@ -613,7 +613,7 @@ Makefile to be used with sphinx-build.
|
||||
|
||||
def main(argv=sys.argv[1:]):
|
||||
# type: (List[str]) -> int
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.init_console(os.path.join(package_dir, 'locale'), 'sphinx')
|
||||
|
||||
if not color_terminal():
|
||||
|
@ -387,7 +387,7 @@ Note: By default this script will not overwrite already created files."""))
|
||||
def main(argv=sys.argv[1:]):
|
||||
# type: (List[str]) -> int
|
||||
"""Parse and check the command line arguments."""
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.init_console(os.path.join(package_dir, 'locale'), 'sphinx')
|
||||
|
||||
parser = get_parser()
|
||||
|
@ -408,7 +408,7 @@ The format of the autosummary directive is documented in the
|
||||
|
||||
def main(argv=sys.argv[1:]):
|
||||
# type: (List[str]) -> None
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.init_console(os.path.join(package_dir, 'locale'), 'sphinx')
|
||||
|
||||
app = DummyApplication()
|
||||
|
@ -22,7 +22,7 @@ from sphinx.deprecation import RemovedInSphinx30Warning
|
||||
|
||||
if False:
|
||||
# For type annotation
|
||||
from typing import Any, Callable, Dict, Iterator, List, Tuple # NOQA
|
||||
from typing import Any, Callable, Dict, Iterable, Iterator, List, Tuple, Union # NOQA
|
||||
|
||||
|
||||
class _TranslationProxy(UserString, object):
|
||||
@ -247,6 +247,27 @@ def init(locale_dirs, language, catalog='sphinx', namespace='general'):
|
||||
return translator, has_translation
|
||||
|
||||
|
||||
def setlocale(category, value=None):
|
||||
# type: (int, Union[str, Iterable[str]]) -> None
|
||||
"""Update locale settings.
|
||||
|
||||
This does not throw any exception even if update fails.
|
||||
This is workaround for Python's bug.
|
||||
|
||||
For more details:
|
||||
|
||||
* https://github.com/sphinx-doc/sphinx/issues/5724
|
||||
* https://bugs.python.org/issue18378#msg215215
|
||||
|
||||
.. note:: Only for internal use. Please don't call this method from extensions.
|
||||
This will be removed in future.
|
||||
"""
|
||||
try:
|
||||
locale.setlocale(category, value)
|
||||
except locale.Error:
|
||||
pass
|
||||
|
||||
|
||||
def init_console(locale_dir, catalog):
|
||||
# type: (unicode, unicode) -> Tuple[NullTranslations, bool]
|
||||
"""Initialize locale for console.
|
||||
|
Loading…
Reference in New Issue
Block a user