10000 bpo-41670: Remove outdated predict macro invocation. (GH-22026) · python/cpython@17b5be0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 17b5be0

Browse files
authored
bpo-41670: Remove outdated predict macro invocation. (GH-22026)
Remove PREDICTion of POP_BLOCK from FOR_ITER.
1 parent 5b0181d commit 17b5be0

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

Lib/test/test_sys_settrace.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,23 @@ def run(tracer):
602602
self.compare_events(doit_async.__code__.co_firstlineno,
603603
tracer.events, events)
604604

605+
def test_loop_in_try_except(self):
606+
# https://bugs.python.org/issue41670
607+
608+
def func():
609+
try:
610+
for i in []: pass
611+
return 1
612+
except:
613+
return 2
614+
615+
self.run_and_compare(func,
616+
[(0, 'call'),
617+
(1, 'line'),
618+
(2, 'line'),
619+
(3, 'line'),
620+
(3, 'return')])
621+
605622

606623
class SkipLineEventsTraceTestCase(TraceTestCase):
607624
"""Repeat the trace tests, but with per-line events skipped"""
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Prevent line trace being skipped on platforms not compiled
2+
with ``USE_COMPUTED_GOTOS``.
3+
Fixes issue where some lines nested within a try-except block
4+
were not being traced on Windows.

Python/ceval.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,7 +2311,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
23112311
}
23122312

23132313
case TARGET(POP_BLOCK): {
2314-
PREDICTED(POP_BLOCK);
23152314
PyFrame_BlockPop(f);
23162315
DISPATCH();
23172316
}
@@ -3366,7 +3365,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int throwflag)
33663365
STACK_SHRINK(1);
33673366
Py_DECREF(iter);
33683367
JUMPBY(oparg);
3369-
PREDICT(POP_BLOCK);
33703368
DISPATCH();
33713369
}
33723370

0 commit comments

Comments
 (0)
0