diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-04-15 13:50:41 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-04-15 13:50:41 (GMT) |
commit | 71e84a6e27da7bfa8351d03ba8e52eb0b5150fb2 (patch) | |
tree | 33f2788f42144e2df258b4d8c89c3b5e3e8f3e2c /Lib | |
parent | b4bd4af8c4adb03978803b5d94241a87e40bdaf9 (diff) | |
parent | 2df6a939164a8aec914086137f1242c205312f72 (diff) | |
download | cpython-71e84a6e27da7bfa8351d03ba8e52eb0b5150fb2.zip cpython-71e84a6e27da7bfa8351d03ba8e52eb0b5150fb2.tar.gz cpython-71e84a6e27da7bfa8351d03ba8e52eb0b5150fb2.tar.bz2 |
#5057: Merge with 3.1.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_peepholer.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py index b7d446f..53719d3 100644 --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -195,6 +195,24 @@ class TestTranforms(unittest.TestCase): asm = dis_single('a="x"*1000') self.assertIn('(1000)', asm) + def test_binary_subscr_on_unicode(self): + # valid code get optimized + asm = dis_single('"foo"[0]') + self.assertIn("('f')", asm) + self.assertNotIn('BINARY_SUBSCR', asm) + asm = dis_single('"\u0061\uffff"[1]') + self.assertIn("('\\uffff')", asm) + self.assertNotIn('BINARY_SUBSCR', asm) + + # invalid code doesn't get optimized + # out of range + asm = dis_single('"fuu"[10]') + self.assertIn('BINARY_SUBSCR', asm) + # non-BMP char (see #5057) + asm = dis_single('"\U00012345"[0]') + self.assertIn('BINARY_SUBSCR', asm) + + def test_folding_of_unaryops_on_constants(self): for line, elem in ( ('-0.5', '(-0.5)'), # unary negative |