summaryrefslogtreecommitdiff
path: root/Lib/test/test_peepholer.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-10-26 08:59:14 +0000
committerRaymond Hettinger <python@rcn.com>2004-10-26 08:59:14 +0000
commitd379e8cfc6667f934c5994c5633e24a40c5cc07d (patch)
treebfccca207c3203c54b0b5ad16117bec39220888c /Lib/test/test_peepholer.py
parent99df84df646e0ebc7c759d6e116ba088173e3d30 (diff)
downloadcpython-d379e8cfc6667f934c5994c5633e24a40c5cc07d.tar.gz
SF bug #1053819: Segfault in tuple_of_constants
Peepholer could be fooled into misidentifying a tuple_of_constants. Added code to count consecutive occurrences of LOAD_CONST. Use the count to weed out the misidentified cases. Added a unittest.
Diffstat (limited to 'Lib/test/test_peepholer.py')
-rw-r--r--Lib/test/test_peepholer.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index 913f805e12..934b57c1e8 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -83,6 +83,23 @@ class TestTranforms(unittest.TestCase):
self.assert_(elem in asm)
self.assert_('BUILD_TUPLE' not in asm)
+ # Bug 1053819: Tuple of constants misidentified when presented with:
+ # . . . opcode_with_arg 100 unary_opcode BUILD_TUPLE 1 . . .
+ # The following would segfault upon compilation
+ def crater():
+ (~[
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ ],)
+
def test_elim_extra_return(self):
# RETURN LOAD_CONST None RETURN --> RETURN
def f(x):