diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-04-07 13:29:52 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-04-07 13:29:52 +0300 |
commit | df05d9254d8098534de4db25e9f6de02c78fff2c (patch) | |
tree | e170986fe398afc42261695c05ecf85a3ed533a3 /sphinx/util/osutil.py | |
parent | d501bc136ce5069e97a5f347dbc694717dddced8 (diff) | |
parent | 70ed093b8b45d19beec391def65125a69cb04518 (diff) |
Merge branch '2.0'
Diffstat (limited to 'sphinx/util/osutil.py')
-rw-r--r-- | sphinx/util/osutil.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py index 4cd646f96..fe98783e7 100644 --- a/sphinx/util/osutil.py +++ b/sphinx/util/osutil.py @@ -20,6 +20,7 @@ from io import StringIO from os import path from sphinx.deprecation import RemovedInSphinx40Warning +from sphinx.testing.path import path as Path if False: # For type annotation @@ -167,15 +168,18 @@ fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() def abspath(pathdir): # type: (str) -> str - pathdir = path.abspath(pathdir) - if isinstance(pathdir, bytes): - try: - pathdir = pathdir.decode(fs_encoding) - except UnicodeDecodeError: - raise UnicodeDecodeError('multibyte filename not supported on ' - 'this filesystem encoding ' - '(%r)' % fs_encoding) - return pathdir + if isinstance(pathdir, Path): + return pathdir.abspath() + else: + pathdir = path.abspath(pathdir) + if isinstance(pathdir, bytes): + try: + pathdir = pathdir.decode(fs_encoding) + except UnicodeDecodeError: + raise UnicodeDecodeError('multibyte filename not supported on ' + 'this filesystem encoding ' + '(%r)' % fs_encoding) + return pathdir def getcwd(): |