diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-10-31 02:26:20 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-10-31 02:26:20 (GMT) |
commit | 084ce7a5dcadc2d1bac565a363ae54bbcb09abd0 (patch) | |
tree | becfcca3c908631d560cc08376d5747a79618168 /Lib | |
parent | f4d016f38a48e15823021b969aa66cabd0f679a8 (diff) | |
download | cpython-084ce7a5dcadc2d1bac565a363ae54bbcb09abd0.zip cpython-084ce7a5dcadc2d1bac565a363ae54bbcb09abd0.tar.gz cpython-084ce7a5dcadc2d1bac565a363ae54bbcb09abd0.tar.bz2 |
Merged revisions 67066 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67066 | benjamin.peterson | 2008-10-30 21:16:05 -0500 (Thu, 30 Oct 2008) | 5 lines
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')
-rw-r--r-- | Lib/test/test_future.py | 5 | ||||
-rw-r--r-- | Lib/test/test_parser.py | 9 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py index 1432e74..81d0a3e 100644 --- a/Lib/test/test_future.py +++ b/Lib/test/test_future.py @@ -106,6 +106,11 @@ class FutureTest(unittest.TestCase): test_support.unload("test.test_future5") from test import test_future5 + def test_unicode_literals_exec(self): + scope = {} + exec "from __future__ import unicode_literals; x = ''" in scope + self.assertTrue(isinstance(scope["x"], unicode)) + def test_main(): test_support.run_unittest(FutureTest) 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) |