summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2014-12-13 21:06:19 (GMT)
committerBenjamin Peterson <benjamin@python.org>2014-12-13 21:06:19 (GMT)
commit3cda0ed062892c46cbae43989ff59399e8042f58 (patch)
tree05e8b96522ce3b7774394365b73df0cdf1275806 /Lib
parentdb9b65d9e5d9d39199714cfd15a26e46ab0eaae1 (diff)
downloadcpython-3cda0ed062892c46cbae43989ff59399e8042f58.zip
cpython-3cda0ed062892c46cbae43989ff59399e8042f58.tar.gz
cpython-3cda0ed062892c46cbae43989ff59399e8042f58.tar.bz2
pop the loop block even for infinite while loops (closes #23048)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_dis.py7
-rw-r--r--Lib/test/test_sys_settrace.py11
2 files changed, 15 insertions, 3 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index d1229fb..b8daff7 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -178,15 +178,16 @@ dis_compound_stmt_str = """\
1 0 LOAD_CONST 0 (0)
3 STORE_NAME 0 (x)
- 2 6 SETUP_LOOP 13 (to 22)
+ 2 6 SETUP_LOOP 14 (to 23)
3 >> 9 LOAD_NAME 0 (x)
12 LOAD_CONST 1 (1)
15 INPLACE_ADD
16 STORE_NAME 0 (x)
19 JUMP_ABSOLUTE 9
- >> 22 LOAD_CONST 2 (None)
- 25 RETURN_VALUE
+ 22 POP_BLOCK
+ >> 23 LOAD_CONST 2 (None)
+ 26 RETURN_VALUE
"""
dis_traceback = """\
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index f0b0b82..ae8f845 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -579,6 +579,15 @@ def jump_in_nested_finally(output):
jump_in_nested_finally.jump = (4, 9)
jump_in_nested_finally.output = [2, 9]
+def jump_infinite_while_loop(output):
+ output.append(1)
+ while 1:
+ output.append(2)
+ output.append(3)
+
+jump_infinite_while_loop.jump = (3, 4)
+jump_infinite_while_loop.output = [1, 3]
+
# The second set of 'jump' tests are for things that are not allowed:
def no_jump_too_far_forwards(output):
@@ -755,6 +764,8 @@ class JumpTestCase(unittest.TestCase):
self.run_test(jump_to_same_line)
def test_07_jump_in_nested_finally(self):
self.run_test(jump_in_nested_finally)
+ def test_jump_infinite_while_loop(self):
+ self.run_test(jump_infinite_while_loop)
def test_08_no_jump_too_far_forwards(self):
self.run_test(no_jump_too_far_forwards)
def test_09_no_jump_too_far_backwards(self):