bpo-41670: Remove outdated predict macro invocation. (GH-22026)
https://github.com/python/cpython/commit/17b5be0c0a3f74141014e06a660f1b5ddb0... commit: 17b5be0c0a3f74141014e06a660f1b5ddb002fec branch: master author: Mark Shannon <mark@hotpy.org> committer: GitHub <noreply@github.com> date: 2020-09-29T10:09:13+01:00 summary: bpo-41670: Remove outdated predict macro invocation. (GH-22026) Remove PREDICTion of POP_BLOCK from FOR_ITER. files: A Misc/NEWS.d/next/Core and Builtins/2020-08-31-11-37-59.bpo-41670.vmRJRx.rst M Lib/test/test_sys_settrace.py M Python/ceval.c diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 3f902b1fe74ce..dd4418dd98b22 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -602,6 +602,23 @@ def run(tracer): 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 index 0000000000000..6ad5fb6dc9bb4 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-08-31-11-37-59.bpo-41670.vmRJRx.rst @@ -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. diff --git a/Python/ceval.c b/Python/ceval.c index 6430e792b8c5d..6bd2d6bc13d86 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2311,7 +2311,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) } case TARGET(POP_BLOCK): { - PREDICTED(POP_BLOCK); PyFrame_BlockPop(f); DISPATCH(); } @@ -3366,7 +3365,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag) STACK_SHRINK(1); Py_DECREF(iter); JUMPBY(oparg); - PREDICT(POP_BLOCK); DISPATCH(); }
participants (1)
-
Mark Shannon