mirror of
https://github.com/python/cpython.git
synced 2025-09-19 07:00:59 +00:00
bpo-42635: Mark JUMP_ABSOLUTE at end of 'for' loop as artificial to avoid spurious line events. (GH-23761)
This commit is contained in:
parent
56aa20f9eb
commit
f5e97b72fe
4 changed files with 3803 additions and 3775 deletions
|
@ -646,6 +646,32 @@ class TraceTestCase(unittest.TestCase):
|
||||||
(6, 'line'),
|
(6, 'line'),
|
||||||
(6, 'return')])
|
(6, 'return')])
|
||||||
|
|
||||||
|
def test_nested_loops(self):
|
||||||
|
|
||||||
|
def func():
|
||||||
|
for i in range(2):
|
||||||
|
for j in range(2):
|
||||||
|
a = i + j
|
||||||
|
return a == 1
|
||||||
|
|
||||||
|
self.run_and_compare(func,
|
||||||
|
[(0, 'call'),
|
||||||
|
(1, 'line'),
|
||||||
|
(2, 'line'),
|
||||||
|
(3, 'line'),
|
||||||
|
(2, 'line'),
|
||||||
|
(3, 'line'),
|
||||||
|
(2, 'line'),
|
||||||
|
(1, 'line'),
|
||||||
|
(2, 'line'),
|
||||||
|
(3, 'line'),
|
||||||
|
(2, 'line'),
|
||||||
|
(3, 'line'),
|
||||||
|
(2, 'line'),
|
||||||
|
(1, 'line'),
|
||||||
|
(4, 'line'),
|
||||||
|
(4, 'return')])
|
||||||
|
|
||||||
|
|
||||||
class SkipLineEventsTraceTestCase(TraceTestCase):
|
class SkipLineEventsTraceTestCase(TraceTestCase):
|
||||||
"""Repeat the trace tests, but with per-line events skipped"""
|
"""Repeat the trace tests, but with per-line events skipped"""
|
||||||
|
|
|
@ -2773,6 +2773,8 @@ compiler_for(struct compiler *c, stmt_ty s)
|
||||||
compiler_use_next_block(c, body);
|
compiler_use_next_block(c, body);
|
||||||
VISIT(c, expr, s->v.For.target);
|
VISIT(c, expr, s->v.For.target);
|
||||||
VISIT_SEQ(c, stmt, s->v.For.body);
|
VISIT_SEQ(c, stmt, s->v.For.body);
|
||||||
|
/* Mark jump as artificial */
|
||||||
|
c->u->u_lineno = -1;
|
||||||
ADDOP_JUMP(c, JUMP_ABSOLUTE, start);
|
ADDOP_JUMP(c, JUMP_ABSOLUTE, start);
|
||||||
compiler_use_next_block(c, cleanup);
|
compiler_use_next_block(c, cleanup);
|
||||||
|
|
||||||
|
|
3520
Python/importlib.h
generated
3520
Python/importlib.h
generated
File diff suppressed because it is too large
Load diff
4030
Python/importlib_external.h
generated
4030
Python/importlib_external.h
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue