mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
GH-94438: Restore ability to jump over None tests (GH-111237)
This commit is contained in:
parent
4fbf20605b
commit
6640f1d8d2
4 changed files with 38 additions and 0 deletions
|
@ -2064,6 +2064,40 @@ class JumpTestCase(unittest.TestCase):
|
||||||
output.append(1)
|
output.append(1)
|
||||||
output.append(2)
|
output.append(2)
|
||||||
|
|
||||||
|
@jump_test(1, 4, [5])
|
||||||
|
def test_jump_is_none_forwards(output):
|
||||||
|
x = None
|
||||||
|
if x is None:
|
||||||
|
output.append(3)
|
||||||
|
else:
|
||||||
|
output.append(5)
|
||||||
|
|
||||||
|
@jump_test(6, 5, [3, 5, 6])
|
||||||
|
def test_jump_is_none_backwards(output):
|
||||||
|
x = None
|
||||||
|
if x is None:
|
||||||
|
output.append(3)
|
||||||
|
else:
|
||||||
|
output.append(5)
|
||||||
|
output.append(6)
|
||||||
|
|
||||||
|
@jump_test(1, 4, [5])
|
||||||
|
def test_jump_is_not_none_forwards(output):
|
||||||
|
x = None
|
||||||
|
if x is not None:
|
||||||
|
output.append(3)
|
||||||
|
else:
|
||||||
|
output.append(5)
|
||||||
|
|
||||||
|
@jump_test(6, 5, [5, 5, 6])
|
||||||
|
def test_jump_is_not_none_backwards(output):
|
||||||
|
x = None
|
||||||
|
if x is not None:
|
||||||
|
output.append(3)
|
||||||
|
else:
|
||||||
|
output.append(5)
|
||||||
|
output.append(6)
|
||||||
|
|
||||||
@jump_test(3, 5, [2, 5], warning=(RuntimeWarning, unbound_locals))
|
@jump_test(3, 5, [2, 5], warning=(RuntimeWarning, unbound_locals))
|
||||||
def test_jump_out_of_block_forwards(output):
|
def test_jump_out_of_block_forwards(output):
|
||||||
for i in 1, 2:
|
for i in 1, 2:
|
||||||
|
|
|
@ -1345,6 +1345,7 @@ Michele Orrù
|
||||||
Tomáš Orsava
|
Tomáš Orsava
|
||||||
Oleg Oshmyan
|
Oleg Oshmyan
|
||||||
Denis Osipov
|
Denis Osipov
|
||||||
|
Savannah Ostrowski
|
||||||
Denis S. Otkidach
|
Denis S. Otkidach
|
||||||
Peter Otten
|
Peter Otten
|
||||||
Michael Otteneder
|
Michael Otteneder
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix a regression that prevented jumping across ``is None`` and ``is not None`` when debugging. Patch by Savannah Ostrowski.
|
|
@ -329,6 +329,8 @@ mark_stacks(PyCodeObject *code_obj, int len)
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case POP_JUMP_IF_FALSE:
|
case POP_JUMP_IF_FALSE:
|
||||||
case POP_JUMP_IF_TRUE:
|
case POP_JUMP_IF_TRUE:
|
||||||
|
case POP_JUMP_IF_NONE:
|
||||||
|
case POP_JUMP_IF_NOT_NONE:
|
||||||
{
|
{
|
||||||
int64_t target_stack;
|
int64_t target_stack;
|
||||||
int j = next_i + oparg;
|
int j = next_i + oparg;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue