mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Closes #1128: Fix Unicode errors when trying to format time strings with a non-standard locale.
This commit is contained in:
parent
b9696a9d9d
commit
77d2a90f36
2
CHANGES
2
CHANGES
@ -160,6 +160,8 @@ Bugs fixed
|
||||
width, table layout width and text wrap width.
|
||||
* Fix leading space in LaTeX table header cells.
|
||||
* #1132: Fix LaTeX table output for multi-row cells in the first column.
|
||||
* #1128: Fix Unicode errors when trying to format time strings with a
|
||||
non-standard locale.
|
||||
* #1127: Fix traceback when autodoc tries to tokenize a non-Python file.
|
||||
* #1126: Fix double-hyphen to en-dash conversion in wrong places such as
|
||||
command-line option names in LaTeX.
|
||||
|
@ -14,6 +14,7 @@ import re
|
||||
import sys
|
||||
import time
|
||||
import errno
|
||||
import locale
|
||||
import shutil
|
||||
from os import path
|
||||
|
||||
@ -135,10 +136,12 @@ def make_filename(string):
|
||||
return no_fn_re.sub('', string)
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
# strftime for unicode strings
|
||||
def ustrftime(format, *args):
|
||||
# strftime for unicode strings
|
||||
return time.strftime(unicode(format).encode('utf-8'), *args) \
|
||||
.decode('utf-8')
|
||||
# if a locale is set, the time strings are encoded in the encoding
|
||||
# given by LC_TIME; if that is available, use it
|
||||
enc = locale.getlocale(locale.LC_TIME)[1] or 'utf-8'
|
||||
return time.strftime(unicode(format).encode(enc), *args).decode(enc)
|
||||
else:
|
||||
ustrftime = time.strftime
|
||||
|
||||
@ -159,4 +162,3 @@ def find_catalog(docname, compaction):
|
||||
return ret
|
||||
|
||||
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user