Commits

Georg Brandl committed 12fea70

#414: fix universal newline handling of files included with "literalinclude".

codecs.open() does not support U in the mode argument; use the EncodedFile wrapper instead.

  • Participants
  • Parent commits 57c0540

Comments (0)

Files changed (2)

 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.

sphinx/directives/code.py

 
         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):