]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41670: Remove outdated predict macro invocation. (GH-22026) 22412/head
authorMark Shannon <mark@hotpy.org>
Tue, 29 Sep 2020 09:09:13 +0000 (10:09 +0100)
committerGitHub <noreply@github.com>
Tue, 29 Sep 2020 09:09:13 +0000 (10:09 +0100)
Remove PREDICTion of POP_BLOCK from FOR_ITER.

Lib/test/test_sys_settrace.py
Misc/NEWS.d/next/Core and Builtins/2020-08-31-11-37-59.bpo-41670.vmRJRx.rst [new file with mode: 0644]
Python/ceval.c

index 3f902b1fe74ce83b4f95c68600b09f9999ede370..dd4418dd98b22a0fa0bfc7fd9e48722bce7d2b8a 100644 (file)
@@ -602,6 +602,23 @@ class TraceTestCase(unittest.TestCase):
         self.compare_events(doit_async.__code__.co_firstlineno,
                             tracer.events, events)
 
+    def test_loop_in_try_except(self):
+        # https://bugs.python.org/issue41670
+
+        def func():
+            try:
+                for i in []: pass
+                return 1
+            except:
+                return 2
+
+        self.run_and_compare(func,
+            [(0, 'call'),
+             (1, 'line'),
+             (2, 'line'),
+             (3, 'line'),
+             (3, 'return')])
+
 
 class SkipLineEventsTraceTestCase(TraceTestCase):
     """Repeat the trace tests, but with per-line events skipped"""
diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-08-31-11-37-59.bpo-41670.vmRJRx.rst b/Misc/NEWS.d/next/Core and Builtins/2020-08-31-11-37-59.bpo-41670.vmRJRx.rst
new file mode 100644 (file)
index 0000000..6ad5fb6
--- /dev/null
@@ -0,0 +1,4 @@
+Prevent line trace being skipped on platforms not compiled
+with ``USE_COMPUTED_GOTOS``.
+Fixes issue where some lines nested within a try-except block
+were not being traced on Windows.
index 6430e792b8c5d8b69529ca9ab5836737be170627..6bd2d6bc13d86f124fba2deedda7981039006f8c 100644 (file)
@@ -2311,7 +2311,6 @@ main_loop:
         }
 
         case TARGET(POP_BLOCK): {
-            PREDICTED(POP_BLOCK);
             PyFrame_BlockPop(f);
             DISPATCH();
         }
@@ -3366,7 +3365,6 @@ main_loop:
             STACK_SHRINK(1);
             Py_DECREF(iter);
             JUMPBY(oparg);
-            PREDICT(POP_BLOCK);
             DISPATCH();
         }