summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakayuki Shimizukawa <shimizukawa@gmail.com>2014-07-13 10:44:48 +0900
committerTakayuki Shimizukawa <shimizukawa@gmail.com>2014-07-13 10:44:48 +0900
commit269421bc5844ec6234b8c37bfb2a5dcbec609f27 (patch)
tree18d9b97776f6a2289ddf1c9ff971f93738c4c1cc
parente2ed97031d847f6615cd34535f7b331d93d2884d (diff)
downloadsphinx-git-269421bc5844ec6234b8c37bfb2a5dcbec609f27.tar.gz
* Fix: Non-ASCII filename raise exception on make singlehtml, latex, man, texinfo and changes. Closes #1508
-rw-r--r--CHANGES2
-rw-r--r--sphinx/builders/changes.py5
-rw-r--r--sphinx/util/nodes.py2
-rw-r--r--tests/test_build.py29
4 files changed, 27 insertions, 11 deletions
diff --git a/CHANGES b/CHANGES
index 86e30df3d..127cb545b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -23,6 +23,8 @@ Bugs fixed
exception and emits warnings without unexpected termination.
* #1503: py:function directive generate incorrectly signature when specifying
a default parameter with an empty list `[]`. Thanks to Geert Jansen.
+* #1508: Non-ASCII filename raise exception on make singlehtml, latex, man,
+ texinfo and changes.
Release 1.2.2 (released Mar 2, 2014)
====================================
diff --git a/sphinx/builders/changes.py b/sphinx/builders/changes.py
index 3a52c713d..c9317af22 100644
--- a/sphinx/builders/changes.py
+++ b/sphinx/builders/changes.py
@@ -124,14 +124,15 @@ class ChangesBuilder(Builder):
self.info(bold('copying source files...'))
for docname in self.env.all_docs:
- f = codecs.open(self.env.doc2path(docname), 'r', 'latin1')
+ f = codecs.open(self.env.doc2path(docname), 'r',
+ self.env.config.source_encoding)
try:
lines = f.readlines()
finally:
f.close()
targetfn = path.join(self.outdir, 'rst', os_path(docname)) + '.html'
ensuredir(path.dirname(targetfn))
- f = codecs.open(targetfn, 'w', 'latin1')
+ f = codecs.open(targetfn, 'w', 'utf-8')
try:
text = ''.join(hl(i+1, line) for (i, line) in enumerate(lines))
ctx = {
diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py
index 1a923d116..baedce4d5 100644
--- a/sphinx/util/nodes.py
+++ b/sphinx/util/nodes.py
@@ -186,7 +186,7 @@ def inline_all_toctrees(builder, docnameset, docname, tree, colorfunc):
tree = tree.deepcopy()
for toctreenode in tree.traverse(addnodes.toctree):
newnodes = []
- includefiles = map(str, toctreenode['includefiles'])
+ includefiles = map(unicode, toctreenode['includefiles'])
for includefile in includefiles:
try:
builder.info(colorfunc(includefile) + " ", nonl=1)
diff --git a/tests/test_build.py b/tests/test_build.py
index f283187c4..c355b1622 100644
--- a/tests/test_build.py
+++ b/tests/test_build.py
@@ -18,16 +18,14 @@ except ImportError:
ManWriter = None
-builder_names = ['pickle', 'json', 'linkcheck', 'text', 'htmlhelp', 'qthelp',
- 'epub', 'changes', 'singlehtml', 'xml', 'pseudoxml']
-
-
def teardown_module():
(test_root / '_build').rmtree(True)
def test_build():
- for buildername in builder_names:
+ for buildername in ('pickle', 'json', 'linkcheck', 'text', 'htmlhelp',
+ 'qthelp', 'epub', 'changes', 'singlehtml', 'xml',
+ 'pseudoxml'):
app = TestApp(buildername=buildername)
yield lambda app: app.builder.build_all(), app
app.cleanup()
@@ -41,8 +39,7 @@ def test_man(app):
assert (app.outdir / 'SphinxTests.1').exists()
-@with_app(buildername='html', srcdir='(temp)')
-def test_nonascii_path(app):
+def _test_nonascii_path(app):
srcdir = path(app.srcdir)
mb_name = u'\u65e5\u672c\u8a9e'
try:
@@ -63,6 +60,22 @@ def test_nonascii_path(app):
.. toctree::
%(mb_name)s/%(mb_name)s
- """ % locals())
+ """ % {'mb_name': mb_name})
).encode('utf-8'))
app.builder.build_all()
+
+
+def test_nonascii_path():
+ (test_root / '_build').rmtree(True) #keep this to build first gettext
+
+ builder_names = ['gettext', 'html', 'dirhtml', 'singlehtml', 'latex',
+ 'texinfo', 'pickle', 'json', 'linkcheck', 'text',
+ 'htmlhelp', 'qthelp', 'epub', 'changes', 'xml',
+ 'pseudoxml']
+ if ManWriter is not None:
+ builder_names.append('man')
+
+ for buildername in builder_names:
+ app = TestApp(buildername=buildername, srcdir='(temp)')
+ yield _test_nonascii_path, app
+ app.cleanup()