]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] GH-94438: Restore ability to jump over None tests (GH-111243)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 24 Oct 2023 06:39:26 +0000 (08:39 +0200)
committerGitHub <noreply@github.com>
Tue, 24 Oct 2023 06:39:26 +0000 (06:39 +0000)
(cherry picked from commit 6640f1d8d2462ca0877e1d2789e1721767e9caf2)
Co-authored-by: Savannah Ostrowski <sostrowski@microsoft.com>
Lib/test/test_sys_settrace.py
Misc/ACKS
Misc/NEWS.d/next/Core and Builtins/2023-10-23-22-11-09.gh-issue-94438.y2pITu.rst [new file with mode: 0644]
Objects/frameobject.c

index c29deeba4b31a2421686ae768b9c549d47a9330f..84088d428c9cc913d095cb8a7e29021346a825ad 100644 (file)
@@ -2033,6 +2033,40 @@ class JumpTestCase(unittest.TestCase):
         output.append(1)
         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))
     def test_jump_out_of_block_forwards(output):
         for i in 1, 2:
index 5bba961158e6845ea8b82309d016336dfe0f8a7e..df377b79c8ba6cc572a46b22f8e3f07801d58513 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1342,6 +1342,7 @@ Michele Orrù
 Tomáš Orsava
 Oleg Oshmyan
 Denis Osipov
+Savannah Ostrowski
 Denis S. Otkidach
 Peter Otten
 Michael Otteneder
diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-10-23-22-11-09.gh-issue-94438.y2pITu.rst b/Misc/NEWS.d/next/Core and Builtins/2023-10-23-22-11-09.gh-issue-94438.y2pITu.rst
new file mode 100644 (file)
index 0000000..b6e147a
--- /dev/null
@@ -0,0 +1 @@
+Fix a regression that prevented jumping across ``is None`` and ``is not None`` when debugging. Patch by Savannah Ostrowski.
index 30c8d3c5270cad6753f5a903dfac01714017d8a3..d33c3cde526e9ff1feae9e35bdefe5a77edf8cf6 100644 (file)
@@ -328,6 +328,8 @@ mark_stacks(PyCodeObject *code_obj, int len)
             switch (opcode) {
                 case POP_JUMP_IF_FALSE:
                 case POP_JUMP_IF_TRUE:
+                case POP_JUMP_IF_NONE:
+                case POP_JUMP_IF_NOT_NONE:
                 {
                     int64_t target_stack;
                     int j = next_i + oparg;