mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Ignore MemoryError while parsing Python source with Python 2.4
(it's raised for invalid coding cookies).
This commit is contained in:
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user