Ignore MemoryError while parsing Python source with Python 2.4

(it's raised for invalid coding cookies).
This commit is contained in:
Georg Brandl
2008-03-19 07:45:14 +00:00
parent 63cf464e30
commit 7b298368d3
+8 -1
View File
@@ -66,6 +66,13 @@ def escape_tex(text):
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
@@ -112,7 +119,7 @@ class PygmentsBridge(object):
try:
parser.suite(src)
except (SyntaxError, UnicodeEncodeError):
except parsing_exceptions:
return unhighlighted()
else:
lexer = lexers['python']