mirror of
https://github.com/python/cpython.git
synced 2025-07-30 14:44:10 +00:00
make sure the parser flags and passed onto the compiler
This fixes "from __future__ import unicode_literals" in an exec statment See #4225
This commit is contained in:
parent
44a90c95ce
commit
dcee09d920
5 changed files with 65 additions and 13 deletions
|
@ -25,6 +25,15 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
|
|||
def check_expr(self, s):
|
||||
self.roundtrip(parser.expr, s)
|
||||
|
||||
def test_flags_passed(self):
|
||||
# The unicode literals flags has to be passed from the paser to AST
|
||||
# generation.
|
||||
suite = parser.suite("from __future__ import unicode_literals; x = ''")
|
||||
code = suite.compile()
|
||||
scope = {}
|
||||
exec code in scope
|
||||
self.assertTrue(isinstance(scope["x"], unicode))
|
||||
|
||||
def check_suite(self, s):
|
||||
self.roundtrip(parser.suite, s)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue