diff options
author | shimizukawa <shimizukawa@gmail.com> | 2015-11-15 18:07:23 +0900 |
---|---|---|
committer | shimizukawa <shimizukawa@gmail.com> | 2015-11-15 18:07:23 +0900 |
commit | 8ae43b9fd4b68473d25e872766a8786a5be85852 (patch) | |
tree | 313d0146f5c8009f0be3e03ce71f1994624872a9 /sphinx/util/osutil.py | |
parent | c4850cc9abcb94eea0fea01127e2b9cb966db56b (diff) | |
parent | df3643722f0116176388604f676d89104ea39800 (diff) | |
download | sphinx-git-8ae43b9fd4b68473d25e872766a8786a5be85852.tar.gz |
Merge branch 'stable'
Diffstat (limited to 'sphinx/util/osutil.py')
-rw-r--r-- | sphinx/util/osutil.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py index 5bfbcabc4..a56da44fe 100644 --- a/sphinx/util/osutil.py +++ b/sphinx/util/osutil.py @@ -166,8 +166,14 @@ def ustrftime(format, *args): # 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: - return time.strftime(format, *args) + else: # Py3 + # 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): |