mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Use the "with" __future__ statement when parsing python snippets.
This commit is contained in:
parent
aeb2e1e3bc
commit
d0121841a6
@ -63,7 +63,8 @@ def highlight_block(source, lang):
|
||||
else:
|
||||
# maybe Python -- try parsing it
|
||||
try:
|
||||
parser.suite(source + '\n')
|
||||
parser.suite('from __future__ import with_statement\n' +
|
||||
source + '\n')
|
||||
except (SyntaxError, UnicodeEncodeError):
|
||||
return '<pre>' + cgi.escape(source) + '</pre>\n'
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user