summaryrefslogtreecommitdiff
path: root/sphinx/util/osutil.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-09-22 22:54:15 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2018-09-22 22:54:15 +0900
commitdc44b0d2a9c52b5c12843cb1a0a6e0aea3c7f4d2 (patch)
treeee090ebec55c1aa6c5b9e19bfbad1ae0bbfb8abe /sphinx/util/osutil.py
parent490e4aed4145659dab000e86269bd7a3dc686318 (diff)
parentb4fab4bf115af984a82b9c509decc0d1c5fe1c41 (diff)
downloadsphinx-git-dc44b0d2a9c52b5c12843cb1a0a6e0aea3c7f4d2.tar.gz
Merge branch 'master' into HEAD
Diffstat (limited to 'sphinx/util/osutil.py')
-rw-r--r--sphinx/util/osutil.py28
1 files changed, 9 insertions, 19 deletions
diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py
index ab1cf4801..38a986f6b 100644
--- a/sphinx/util/osutil.py
+++ b/sphinx/util/osutil.py
@@ -13,7 +13,6 @@ from __future__ import print_function
import contextlib
import errno
import filecmp
-import locale
import os
import re
import shutil
@@ -23,7 +22,7 @@ import warnings
from io import BytesIO, StringIO
from os import path
-from six import PY2, PY3, text_type
+from six import text_type
from sphinx.deprecation import RemovedInSphinx30Warning, RemovedInSphinx40Warning
@@ -37,9 +36,6 @@ ENOENT = getattr(errno, 'ENOENT', 0)
EPIPE = getattr(errno, 'EPIPE', 0)
EINVAL = getattr(errno, 'EINVAL', 0)
-if PY3:
- unicode = str # special alias for static typing...
-
# SEP separates path elements in the canonical file names
#
# Define SEP as a manifest constant, not so much because we expect it to change
@@ -195,19 +191,13 @@ def ustrftime(format, *args):
if source_date_epoch is not None:
time_struct = time.gmtime(float(source_date_epoch))
args = [time_struct] # type: ignore
- if PY2:
- # 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(text_type(format).encode(enc), *args).decode(enc)
- else: # Py3
- # On Windows, time.strftime() and Unicode characters will raise UnicodeEncodeError.
- # https://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')
+ # On Windows, time.strftime() and Unicode characters will raise UnicodeEncodeError.
+ # https://bugs.python.org/issue8304
+ try:
+ return time.strftime(format, *args) # type: ignore
+ except UnicodeEncodeError:
+ r = time.strftime(format.encode('unicode-escape').decode(), *args) # type: ignore
+ return r.encode().decode('unicode-escape')
def relpath(path, start=os.curdir):
@@ -235,7 +225,7 @@ def abspath(pathdir):
try:
pathdir = pathdir.decode(fs_encoding)
except UnicodeDecodeError:
- raise UnicodeDecodeError('multibyte filename not supported on '
+ raise UnicodeDecodeError('multibyte filename not supported on ' # type: ignore
'this filesystem encoding '
'(%r)' % fs_encoding)
return pathdir