summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-06-12 12:18:43 (GMT)
committerGitHub <noreply@github.com>2024-06-12 12:18:43 (GMT)
commit39825a7533ccf1aa0343d14fe88015db4ee6ef93 (patch)
tree8b9b1bddf36deba3a91fa81e2a9784517603fa15 /Python
parent10821ccf0671a5d660ab5df7b5d4bfa0e9c8d112 (diff)
downloadcpython-39825a7533ccf1aa0343d14fe88015db4ee6ef93.zip
cpython-39825a7533ccf1aa0343d14fe88015db4ee6ef93.tar.gz
cpython-39825a7533ccf1aa0343d14fe88015db4ee6ef93.tar.bz2
[3.13] gh-93691: fix too broad source locations of for statement iterators (GH-120330) (#120399)
gh-93691: fix too broad source locations of for statement iterators (GH-120330) (cherry picked from commit 97b69db167be28a33688db436551a6c3c3ea4662) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
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 949b964..a24764c 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -3101,11 +3101,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);