summaryrefslogtreecommitdiff
path: root/sphinx/util/osutil.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-04-08 23:35:59 +0900
committerGitHub <noreply@github.com>2018-04-08 23:35:59 +0900
commit7e1707000feb43b5ea0d1dffe0c5cb1b9dfc268e (patch)
tree9a3505a4f74f94d04afcce852f52e318347de427 /sphinx/util/osutil.py
parent651d41e1c703a875c6270f5fbbf379d1d4e6a981 (diff)
parentcff8dc519b79f1408b5b8a1b08a6f2bde2274a03 (diff)
downloadsphinx-git-7e1707000feb43b5ea0d1dffe0c5cb1b9dfc268e.tar.gz
Merge pull request #4807 from tk0miya/4783_relpath
Fix #4783: Sphinx crashed when drives of srcdir and outdir are different
Diffstat (limited to 'sphinx/util/osutil.py')
-rw-r--r--sphinx/util/osutil.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/sphinx/util/osutil.py b/sphinx/util/osutil.py
index af87caf9a..fdcbda9a6 100644
--- a/sphinx/util/osutil.py
+++ b/sphinx/util/osutil.py
@@ -205,14 +205,21 @@ def ustrftime(format, *args):
return r.encode().decode('unicode-escape')
-def safe_relpath(path, start=None):
+def relpath(path, start=os.curdir):
# type: (unicode, unicode) -> unicode
+ """Return a relative filepath to *path* either from the current directory or
+ from an optional *start* directory.
+
+ This is an alternative of ``os.path.relpath()``. This returns original path
+ if *path* and *start* are on different drives (for Windows platform).
+ """
try:
return os.path.relpath(path, start)
except ValueError:
return path
+safe_relpath = relpath # for compatibility
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding() # type: unicode