Commits

Takayuki Shimizukawa  committed 4b35ef8

fix for Python3.1: Python 3.1 can't proceess '\r' at parser; `parser.suite("print('hello')\r\n")` cause error.

  • Participants
  • Parent commits 15c9d21

Comments (0)

Files changed (1)

File sphinx/highlighting.py

             # just replace all non-ASCII characters.
             src = src.encode('ascii', 'replace')
 
+        if sys.version_info < (3, 2):
+            # Python 3.1 can't proceess '\r' as linesep.
+            # `parser.suite("print('hello')\r\n")` cause error.
+            if '\r\n' in src:
+                src = src.replace('\r\n', '\n')
+
         if parser is None:
             return True