mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #1512 env.record_dependency crashes on multibyte directories
This commit is contained in:
parent
c884bfacab
commit
873efc5358
@ -39,7 +39,7 @@ from sphinx.util import url_re, get_matching_docs, docname_join, split_into, \
|
|||||||
from sphinx.util.nodes import clean_astext, make_refnode, WarningStream
|
from sphinx.util.nodes import clean_astext, make_refnode, WarningStream
|
||||||
from sphinx.util.osutil import SEP, fs_encoding, find_catalog_files
|
from sphinx.util.osutil import SEP, fs_encoding, find_catalog_files
|
||||||
from sphinx.util.matching import compile_matchers
|
from sphinx.util.matching import compile_matchers
|
||||||
from sphinx.util.pycompat import class_types
|
from sphinx.util.pycompat import class_types, getcwd
|
||||||
from sphinx.util.compat import docutils_version
|
from sphinx.util.compat import docutils_version
|
||||||
from sphinx.util.websupport import is_commentable
|
from sphinx.util.websupport import is_commentable
|
||||||
from sphinx.errors import SphinxError, ExtensionError
|
from sphinx.errors import SphinxError, ExtensionError
|
||||||
@ -760,7 +760,7 @@ class BuildEnvironment:
|
|||||||
|
|
||||||
def process_dependencies(self, docname, doctree):
|
def process_dependencies(self, docname, doctree):
|
||||||
"""Process docutils-generated dependency info."""
|
"""Process docutils-generated dependency info."""
|
||||||
cwd = os.getcwd()
|
cwd = getcwd()
|
||||||
frompath = path.join(path.normpath(self.srcdir), 'dummy')
|
frompath = path.join(path.normpath(self.srcdir), 'dummy')
|
||||||
deps = doctree.settings.record_dependencies
|
deps = doctree.settings.record_dependencies
|
||||||
if not deps:
|
if not deps:
|
||||||
|
@ -25,6 +25,8 @@ if sys.version_info >= (3, 0):
|
|||||||
bytes = bytes
|
bytes = bytes
|
||||||
# prefix for Unicode strings
|
# prefix for Unicode strings
|
||||||
u = ''
|
u = ''
|
||||||
|
# getcwd function
|
||||||
|
from os import getcwd
|
||||||
# StringIO/BytesIO classes
|
# StringIO/BytesIO classes
|
||||||
from io import StringIO, BytesIO, TextIOWrapper
|
from io import StringIO, BytesIO, TextIOWrapper
|
||||||
# safely encode a string for printing to the terminal
|
# safely encode a string for printing to the terminal
|
||||||
@ -58,6 +60,7 @@ else:
|
|||||||
b = str
|
b = str
|
||||||
bytes = str
|
bytes = str
|
||||||
u = 'u'
|
u = 'u'
|
||||||
|
from os import getcwdu as getcwd
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
BytesIO = StringIO
|
BytesIO = StringIO
|
||||||
# no need to refactor on 2.x versions
|
# no need to refactor on 2.x versions
|
||||||
|
@ -8,9 +8,11 @@
|
|||||||
:copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import tempfile
|
||||||
|
|
||||||
from util import TestApp, remove_unicode_literals, path
|
from util import TestApp, test_root, remove_unicode_literals, path
|
||||||
|
|
||||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||||
from sphinx.builders.latex import LaTeXBuilder
|
from sphinx.builders.latex import LaTeXBuilder
|
||||||
@ -95,6 +97,29 @@ def test_second_update():
|
|||||||
assert 'autodoc' not in env.all_docs
|
assert 'autodoc' not in env.all_docs
|
||||||
assert 'autodoc' not in env.found_docs
|
assert 'autodoc' not in env.found_docs
|
||||||
|
|
||||||
|
|
||||||
|
def test_record_dependency_on_multibyte_directory():
|
||||||
|
app = None
|
||||||
|
olddir = os.getcwd()
|
||||||
|
try:
|
||||||
|
tmproot = path(os.path.abspath(tempfile.mkdtemp()))
|
||||||
|
tmpdir = tmproot / u'テスト'
|
||||||
|
test_root.copytree(tmpdir)
|
||||||
|
os.chdir(tmpdir)
|
||||||
|
tmpdir = path(os.getcwd()) # for MacOSX; tmpdir is based on symlinks
|
||||||
|
|
||||||
|
app = TestApp(srcdir=tmpdir, freshenv=True)
|
||||||
|
(app.srcdir / 'test.txt').write_text('.. include:: test.inc')
|
||||||
|
(app.srcdir / 'test.inc').write_text('hello sphinx')
|
||||||
|
_, _, it = app.env.update(app.config, app.srcdir, app.doctreedir, app)
|
||||||
|
list(it) # take all from iterator
|
||||||
|
finally:
|
||||||
|
tmproot.rmtree(ignore_errors=True)
|
||||||
|
os.chdir(olddir)
|
||||||
|
if app:
|
||||||
|
app.cleanup()
|
||||||
|
|
||||||
|
|
||||||
def test_object_inventory():
|
def test_object_inventory():
|
||||||
refs = env.domaindata['py']['objects']
|
refs = env.domaindata['py']['objects']
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user