mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#570: Try decoding `-D
and
-A
` command-line arguments with the locale's preferred encoding.
This commit is contained in:
parent
417571176b
commit
54e1ab93ba
3
CHANGES
3
CHANGES
@ -1,6 +1,9 @@
|
||||
Release 1.0.6 (in development)
|
||||
==============================
|
||||
|
||||
* #570: Try decoding ``-D`` and ``-A`` command-line arguments with
|
||||
the locale's preferred encoding.
|
||||
|
||||
* #528: Observe :confval:`locale_dirs` when looking for the JS
|
||||
translations file.
|
||||
|
||||
|
@ -90,6 +90,13 @@ def main(argv):
|
||||
if err:
|
||||
return 1
|
||||
|
||||
# likely encoding used for command-line arguments
|
||||
try:
|
||||
locale = __import__('locale') # due to submodule of the same name
|
||||
likely_encoding = locale.getpreferredencoding()
|
||||
except Exception:
|
||||
likely_encoding = None
|
||||
|
||||
buildername = None
|
||||
force_all = freshenv = warningiserror = use_pdb = False
|
||||
status = sys.stdout
|
||||
@ -129,7 +136,11 @@ def main(argv):
|
||||
try:
|
||||
val = int(val)
|
||||
except ValueError:
|
||||
pass
|
||||
if likely_encoding:
|
||||
try:
|
||||
val = val.decode(likely_encoding)
|
||||
except UnicodeError:
|
||||
pass
|
||||
confoverrides[key] = val
|
||||
elif opt == '-A':
|
||||
try:
|
||||
@ -141,7 +152,11 @@ def main(argv):
|
||||
try:
|
||||
val = int(val)
|
||||
except ValueError:
|
||||
pass
|
||||
if likely_encoding:
|
||||
try:
|
||||
val = val.decode(likely_encoding)
|
||||
except UnicodeError:
|
||||
pass
|
||||
confoverrides['html_context.%s' % key] = val
|
||||
elif opt == '-n':
|
||||
confoverrides['nitpicky'] = True
|
||||
|
Loading…
Reference in New Issue
Block a user