diff --git a/CHANGES b/CHANGES index c9275c720..f3435ab2d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ Release 0.6.6 (in development) ============================== +* #414: Fix handling of Windows newlines in files included with + the ``literalinclude`` directive. + * #377: Fix crash in linkcheck builder. * #387: Fix the display of search results in ``dirhtml`` output. diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index f5a8f8af4..65bd01227 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -116,7 +116,7 @@ class LiteralInclude(Directive): encoding = self.options.get('encoding', env.config.source_encoding) try: - f = codecs.open(fn, 'rU', encoding) + f = codecs.EncodedFile(open(fn, 'U'), encoding) lines = f.readlines() f.close() except (IOError, OSError):