Fixed #2102: On Windows + Py3, using `|today|` and non-ASCII date format will raise UnicodeEncodeError.

This commit is contained in:
shimizukawa
2015-10-27 00:16:18 +09:00
parent f26f716d59
commit df3643722f
2 changed files with 11 additions and 2 deletions

View File

@@ -59,6 +59,8 @@ Bugs fixed
transforming.
* On Py2 environment, conf.py that is generated by sphinx-quickstart should have u prefixed
config value for 'version' and 'release'.
* #2102: On Windows + Py3, using ``|today|`` and non-ASCII date format will raise
UnicodeEncodeError.
Release 1.3.1 (released Mar 17, 2015)
=====================================

View File

@@ -158,8 +158,15 @@ if PY2:
# given by LC_TIME; if that is available, use it
enc = locale.getlocale(locale.LC_TIME)[1] or 'utf-8'
return time.strftime(text_type(format).encode(enc), *args).decode(enc)
else:
ustrftime = time.strftime
else: # Py3
def ustrftime(format, *args):
# On Windows, time.strftime() and Unicode characters will raise UnicodeEncodeError.
# http://bugs.python.org/issue8304
try:
return time.strftime(format, *args)
except UnicodeEncodeError:
r = time.strftime(format.encode('unicode-escape').decode(), *args)
return r.encode().decode('unicode-escape')
def safe_relpath(path, start=None):