Skip to content

Commit

Permalink
Fix sphinx-doc#8959: using UNIX path separator confuses Sphinx on Win…
Browse files Browse the repository at this point in the history
…dows

The first element of env.relfn2path() should be a OS dependent path, not
a posix path.
  • Loading branch information
tk0miya committed Mar 19, 2021
1 parent 4f8cb86 commit e458ead
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -13,6 +13,8 @@ Deprecated
Features added
--------------

* #8959: using UNIX path separator in image directive confuses Sphinx on Windows

Bugs fixed
----------

Expand Down
5 changes: 3 additions & 2 deletions sphinx/environment/__init__.py
Expand Up @@ -10,7 +10,6 @@

import os
import pickle
import posixpath
import warnings
from collections import defaultdict
from copy import copy
Expand All @@ -34,6 +33,7 @@
from sphinx.util.docutils import LoggingReporter
from sphinx.util.i18n import CatalogRepository, docname_to_domain
from sphinx.util.nodes import is_translatable
from sphinx.util.osutil import os_path

if False:
# For type annotation
Expand Down Expand Up @@ -351,14 +351,15 @@ def relfn2path(self, filename: str, docname: str = None) -> Tuple[str, str]:
source dir, while relative filenames are relative to the dir of the
containing document.
"""
filename = os_path(filename)
if filename.startswith('/') or filename.startswith(os.sep):
rel_fn = filename[1:]
else:
docdir = path.dirname(self.doc2path(docname or self.docname,
base=None))
rel_fn = path.join(docdir, filename)

return (posixpath.normpath(rel_fn),
return (path.normpath(rel_fn),
path.normpath(path.join(self.srcdir, rel_fn)))

@property
Expand Down

0 comments on commit e458ead

Please sign in to comment.