summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2024-06-12 11:53:19 (GMT)
committerGitHub <noreply@github.com>2024-06-12 11:53:19 (GMT)
commit97b69db167be28a33688db436551a6c3c3ea4662 (patch)
treef330280cdb1e39fc5277ae014eb959034154d07d /Python
parent755dab719dfc924dd8aef46f67512dabb8f25071 (diff)
downloadcpython-97b69db167be28a33688db436551a6c3c3ea4662.zip
cpython-97b69db167be28a33688db436551a6c3c3ea4662.tar.gz
cpython-97b69db167be28a33688db436551a6c3c3ea4662.tar.bz2
gh-93691: fix too broad source locations of for statement iterators (#120330)
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Python/compile.c b/Python/compile.c
index c337276..749b69f 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -3025,11 +3025,18 @@ compiler_for(struct compiler *c, stmt_ty s)
RETURN_IF_ERROR(compiler_push_fblock(c, loc, FOR_LOOP, start, end, NULL));
VISIT(c, expr, s->v.For.iter);
+
+ loc = LOC(s->v.For.iter);
ADDOP(c, loc, GET_ITER);
USE_LABEL(c, start);
ADDOP_JUMP(c, loc, FOR_ITER, cleanup);
+ /* Add NOP to ensure correct line tracing of multiline for statements.
+ * It will be removed later if redundant.
+ */
+ ADDOP(c, LOC(s->v.For.target), NOP);
+
USE_LABEL(c, body);
VISIT(c, expr, s->v.For.target);
VISIT_SEQ(c, stmt, s->v.For.body);