Commits

Anonymous committed f094117

Ignore MemoryError while parsing Python source with Python 2.4
(it's raised for invalid coding cookies).

  • Participants
  • Parent commits ba99e8a

Comments (0)

Files changed (1)

File sphinx/highlighting.py

                 replace('\x02', '@rb[]')
 
 
+parsing_exceptions = (SyntaxError, UnicodeEncodeError)
+if sys.version_info < (2, 5):
+    # Python <= 2.4 raises MemoryError when parsing an
+    # invalid encoding cookie
+    parsing_exceptions += MemoryError,
+
+
 class PygmentsBridge(object):
     def __init__(self, dest='html', stylename='sphinx'):
         self.dest = dest
 
                 try:
                     parser.suite(src)
-                except (SyntaxError, UnicodeEncodeError):
+                except parsing_exceptions:
                     return unhighlighted()
                 else:
                     lexer = lexers['python']