mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix a few missing Unicode/bytes filename problems.
This commit is contained in:
@@ -130,6 +130,9 @@ class ChangesBuilder(Builder):
|
||||
self.env.config.source_encoding)
|
||||
try:
|
||||
lines = f.readlines()
|
||||
except UnicodeDecodeError:
|
||||
self.warn('could not read %r for changelog creation' % docname)
|
||||
continue
|
||||
finally:
|
||||
f.close()
|
||||
targetfn = path.join(self.outdir, 'rst', os_path(docname)) + '.html'
|
||||
|
||||
@@ -47,7 +47,6 @@ class Highlight(Directive):
|
||||
linenothreshold=linenothreshold)]
|
||||
|
||||
|
||||
|
||||
def dedent_lines(lines, dedent):
|
||||
if not dedent:
|
||||
return lines
|
||||
@@ -93,7 +92,7 @@ class CodeBlock(Directive):
|
||||
return [document.reporter.warning(str(err), line=self.lineno)]
|
||||
else:
|
||||
hl_lines = None
|
||||
|
||||
|
||||
if 'dedent' in self.options:
|
||||
lines = code.split('\n')
|
||||
lines = dedent_lines(lines, self.options['dedent'])
|
||||
|
||||
@@ -39,7 +39,7 @@ from sphinx import addnodes
|
||||
from sphinx.util import url_re, get_matching_docs, docname_join, split_into, \
|
||||
FilenameUniqDict
|
||||
from sphinx.util.nodes import clean_astext, make_refnode, WarningStream
|
||||
from sphinx.util.osutil import SEP, find_catalog_files
|
||||
from sphinx.util.osutil import SEP, find_catalog_files, getcwd, fs_encoding
|
||||
from sphinx.util.matching import compile_matchers
|
||||
from sphinx.util.websupport import is_commentable
|
||||
from sphinx.errors import SphinxError, ExtensionError
|
||||
@@ -774,7 +774,7 @@ class BuildEnvironment:
|
||||
|
||||
def process_dependencies(self, docname, doctree):
|
||||
"""Process docutils-generated dependency info."""
|
||||
cwd = os.getcwd()
|
||||
cwd = getcwd()
|
||||
frompath = path.join(path.normpath(self.srcdir), 'dummy')
|
||||
deps = doctree.settings.record_dependencies
|
||||
if not deps:
|
||||
@@ -782,6 +782,8 @@ class BuildEnvironment:
|
||||
for dep in deps.list:
|
||||
# the dependency path is relative to the working dir, so get
|
||||
# one relative to the srcdir
|
||||
if isinstance(dep, bytes):
|
||||
dep = dep.decode(fs_encoding)
|
||||
relpath = relative_path(frompath,
|
||||
path.normpath(path.join(cwd, dep)))
|
||||
self.dependencies.setdefault(docname, set()).add(relpath)
|
||||
|
||||
@@ -31,13 +31,14 @@ import jinja2
|
||||
import sphinx
|
||||
from sphinx.errors import PycodeError
|
||||
from sphinx.util.console import strip_colors
|
||||
from sphinx.util.osutil import fs_encoding
|
||||
|
||||
# import other utilities; partly for backwards compatibility, so don't
|
||||
# prune unused ones indiscriminately
|
||||
from sphinx.util.osutil import SEP, os_path, relative_uri, ensuredir, walk, \
|
||||
mtimes_of_files, movefile, copyfile, copytimes, make_filename, ustrftime
|
||||
mtimes_of_files, movefile, copyfile, copytimes, make_filename, ustrftime
|
||||
from sphinx.util.nodes import nested_parse_with_titles, split_explicit_title, \
|
||||
explicit_title_re, caption_ref_re
|
||||
explicit_title_re, caption_ref_re
|
||||
from sphinx.util.matching import patfilter
|
||||
|
||||
# Generally useful regular expressions.
|
||||
@@ -200,10 +201,12 @@ def save_traceback(app):
|
||||
last_msgs)).encode('utf-8'))
|
||||
if app is not None:
|
||||
for extname, extmod in iteritems(app._extensions):
|
||||
modfile = getattr(extmod, '__file__', 'unknown')
|
||||
if isinstance(modfile, bytes):
|
||||
modfile = modfile.decode(fs_encoding, 'replace')
|
||||
os.write(fd, ('# %s (%s) from %s\n' % (
|
||||
extname, app._extension_versions[extname],
|
||||
getattr(extmod, '__file__', 'unknown'))
|
||||
).encode('utf-8'))
|
||||
modfile)).encode('utf-8'))
|
||||
os.write(fd, exc.encode('utf-8'))
|
||||
os.close(fd)
|
||||
return path
|
||||
|
||||
@@ -194,3 +194,9 @@ def abspath(pathdir):
|
||||
if isinstance(pathdir, bytes):
|
||||
pathdir = pathdir.decode(fs_encoding)
|
||||
return pathdir
|
||||
|
||||
|
||||
def getcwd():
|
||||
if hasattr(os, 'getcwdu'):
|
||||
return os.getcwdu()
|
||||
return os.getcwd()
|
||||
|
||||
Reference in New Issue
Block a user