diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-04 22:03:21 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-04 22:03:21 (GMT) |
commit | c18cc0edff5269d715f9aa06ca31a4f19ff87b30 (patch) | |
tree | d36a8118799acf48879a693344175b746dd2492e /Lib/test | |
parent | 51c374dede0e81ec508c552d21faf019da0b6b20 (diff) | |
download | cpython-c18cc0edff5269d715f9aa06ca31a4f19ff87b30.zip cpython-c18cc0edff5269d715f9aa06ca31a4f19ff87b30.tar.gz cpython-c18cc0edff5269d715f9aa06ca31a4f19ff87b30.tar.bz2 |
#5057: the peepholer no longer optimizes subscription on unicode literals (e.g. u"foo"[0]) in order to produce compatible pyc files between narrow and wide builds.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_peepholer.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py index 3e8b7ae..7e05f49 100644 --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -138,21 +138,22 @@ class TestTranforms(unittest.TestCase): self.assertIn('(1000)', asm) def test_binary_subscr_on_unicode(self): - # valid code get optimized + # unicode strings don't get optimized asm = dis_single('u"foo"[0]') - self.assertIn("(u'f')", asm) - self.assertNotIn('BINARY_SUBSCR', asm) + self.assertNotIn("(u'f')", asm) + self.assertIn('BINARY_SUBSCR', asm) asm = dis_single('u"\u0061\uffff"[1]') - self.assertIn("(u'\\uffff')", asm) - self.assertNotIn('BINARY_SUBSCR', asm) + self.assertNotIn("(u'\\uffff')", asm) + self.assertIn('BINARY_SUBSCR', asm) - # invalid code doesn't get optimized # out of range asm = dis_single('u"fuu"[10]') self.assertIn('BINARY_SUBSCR', asm) # non-BMP char (see #5057) asm = dis_single('u"\U00012345"[0]') self.assertIn('BINARY_SUBSCR', asm) + asm = dis_single('u"\U00012345abcdef"[3]') + self.assertIn('BINARY_SUBSCR', asm) def test_folding_of_unaryops_on_constants(self): |