summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_parser.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-10-31 02:16:05 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-10-31 02:16:05 (GMT)
commitdcee09d9204957ace381b1c3507259f718aa4907 (patch)
treebb1bee26c4b535f8e9dd75f25a1ef1a72735e880 /Lib/test/test_parser.py
parent44a90c95ceb6d6348dd7f81db33287f09112118d (diff)
downloadcpython-dcee09d9204957ace381b1c3507259f718aa4907.zip
cpython-dcee09d9204957ace381b1c3507259f718aa4907.tar.gz
cpython-dcee09d9204957ace381b1c3507259f718aa4907.tar.bz2
make sure the parser flags and passed onto the compiler
This fixes "from __future__ import unicode_literals" in an exec statment See #4225
Diffstat (limited to 'Lib/test/test_parser.py')
-rw-r--r--Lib/test/test_parser.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index ba77bb8..9ecca51 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -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)