#227: Make `literalinclude` work when the document's path

name contains non-ASCII characters.
This commit is contained in:
Georg Brandl
2009-08-06 22:29:31 +02:00
parent c914884f57
commit ea5b0088fa
2 changed files with 10 additions and 1 deletions

View File

@@ -1,6 +1,9 @@
Release 0.6.3 (in development)
==============================
* #227: Make ``literalinclude`` work when the document's path
name contains non-ASCII characters.
* #229: Fix autodoc failures with members that raise errors
on ``getattr()``.

View File

@@ -101,7 +101,13 @@ class LiteralInclude(Directive):
else:
docdir = path.dirname(env.doc2path(env.docname, base=None))
rel_fn = path.normpath(path.join(docdir, filename))
fn = path.join(env.srcdir, rel_fn)
try:
fn = path.join(env.srcdir, rel_fn)
except UnicodeDecodeError:
# the source directory is a bytestring with non-ASCII characters;
# let's try to encode the rel_fn in the file system encoding
rel_fn = rel_fn.encode(sys.getfilesystemencoding())
fn = path.join(env.srcdir, rel_fn)
if 'pyobject' in self.options and 'lines' in self.options:
return [document.reporter.warning(