Skip to content

Commit a721258

Browse files
Savannah OstrowskiGlyphack
Savannah Ostrowski
authored andcommitted
pythonGH-94438: Restore ability to jump over None tests (pythonGH-111237)
1 parent af28018 commit a721258

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

Lib/test/test_sys_settrace.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,40 @@ def test_jump_simple_backwards(output):
20642064
output.append(1)
20652065
output.append(2)
20662066

2067+
@jump_test(1, 4, [5])
2068+
def test_jump_is_none_forwards(output):
2069+
x = None
2070+
if x is None:
2071+
output.append(3)
2072+
else:
2073+
output.append(5)
2074+
2075+
@jump_test(6, 5, [3, 5, 6])
2076+
def test_jump_is_none_backwards(output):
2077+
x = None
2078+
if x is None:
2079+
output.append(3)
2080+
else:
2081+
output.append(5)
2082+
output.append(6)
2083+
2084+
@jump_test(1, 4, [5])
2085+
def test_jump_is_not_none_forwards(output):
2086+
x = None
2087+
if x is not None:
2088+
output.append(3)
2089+
else:
2090+
output.append(5)
2091+
2092+
@jump_test(6, 5, [5, 5, 6])
2093+
def test_jump_is_not_none_backwards(output):
2094+
x = None
2095+
if x is not None:
2096+
output.append(3)
2097+
else:
2098+
output.append(5)
2099+
output.append(6)
2100+
20672101
@jump_test(3, 5, [2, 5], warning=(RuntimeWarning, unbound_locals))
20682102
def test_jump_out_of_block_forwards(output):
20692103
for i in 1, 2:

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,7 @@ Michele Orrù
13451345
Tomáš Orsava
13461346
Oleg Oshmyan
13471347
Denis Osipov
1348+
Savannah Ostrowski
13481349
Denis S. Otkidach
13491350
Peter Otten
13501351
Michael Otteneder
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a regression that prevented jumping across ``is None`` and ``is not None`` when debugging. Patch by Savannah Ostrowski.

Objects/frameobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ mark_stacks(PyCodeObject *code_obj, int len)
329329
switch (opcode) {
330330
case POP_JUMP_IF_FALSE:
331331
case POP_JUMP_IF_TRUE:
332+
case POP_JUMP_IF_NONE:
333+
case POP_JUMP_IF_NOT_NONE:
332334
{
333335
int64_t target_stack;
334336
int j = next_i + oparg;

0 commit comments

Comments
 (0)