diff --git a/CHANGES b/CHANGES index 4eb24cd9a..824fbaa01 100644 --- a/CHANGES +++ b/CHANGES @@ -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()``. diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index 645bc7844..6aaf44b86 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -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(