Skip to content

Commit 0bbdfe6

Browse files
miss-islingtonSavannah Ostrowski
and
Savannah Ostrowski
authored
[3.12] GH-94438: Restore ability to jump over None tests (GH-111243)
(cherry picked from commit 6640f1d) Co-authored-by: Savannah Ostrowski <[email protected]>
1 parent b622c2d commit 0bbdfe6

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
@@ -2033,6 +2033,40 @@ def test_jump_simple_backwards(output):
20332033
output.append(1)
20342034
output.append(2)
20352035

2036+
@jump_test(1, 4, [5])
2037+
def test_jump_is_none_forwards(output):
2038+
x = None
2039+
if x is None:
2040+
output.append(3)
2041+
else:
2042+
output.append(5)
2043+
2044+
@jump_test(6, 5, [3, 5, 6])
2045+
def test_jump_is_none_backwards(output):
2046+
x = None
2047+
if x is None:
2048+
output.append(3)
2049+
else:
2050+
output.append(5)
2051+
output.append(6)
2052+
2053+
@jump_test(1, 4, [5])
2054+
def test_jump_is_not_none_forwards(output):
2055+
x = None
2056+
if x is not None:
2057+
output.append(3)
2058+
else:
2059+
output.append(5)
2060+
2061+
@jump_test(6, 5, [5, 5, 6])
2062+
def test_jump_is_not_none_backwards(output):
2063+
x = None
2064+
if x is not None:
2065+
output.append(3)
2066+
else:
2067+
output.append(5)
2068+
output.append(6)
2069+
20362070
@jump_test(3, 5, [2, 5], warning=(RuntimeWarning, unbound_locals))
20372071
def test_jump_out_of_block_forwards(output):
20382072
for i in 1, 2:

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,7 @@ Michele Orrù
13421342
Tomáš Orsava
13431343
Oleg Oshmyan
13441344
Denis Osipov
1345+
Savannah Ostrowski
13451346
Denis S. Otkidach
13461347
Peter Otten
13471348
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
@@ -328,6 +328,8 @@ mark_stacks(PyCodeObject *code_obj, int len)
328328
switch (opcode) {
329329
case POP_JUMP_IF_FALSE:
330330
case POP_JUMP_IF_TRUE:
331+
case POP_JUMP_IF_NONE:
332+
case POP_JUMP_IF_NOT_NONE:
331333
{
332334
int64_t target_stack;
333335
int j = next_i + oparg;

0 commit comments

Comments
 (0)