diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-04-01 17:46:44 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-04-02 23:03:02 +0900 |
commit | cff8dc519b79f1408b5b8a1b08a6f2bde2274a03 (patch) | |
tree | 6966426bd3fe7b90d5f80319d79f82967192cf4a /sphinx/util/osutil.py | |
parent | eb1e8f937c6a48d65f96bd00c00106122cea2efd (diff) | |
download | sphinx-git-cff8dc519b79f1408b5b8a1b08a6f2bde2274a03.tar.gz |
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.py | 9 |
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 |