summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-09-02 14:53:39 (GMT)
committerGitHub <noreply@github.com>2024-09-02 14:53:39 (GMT)
commit494181e44db809204f55eaebc88a255acb09a18f (patch)
tree328eae3eef4e77450bebabf780f64b217ae94ded /Python/compile.c
parent3b3a1a8e7ebbd824778d16fad457a3fa15a9f7e4 (diff)
downloadcpython-494181e44db809204f55eaebc88a255acb09a18f.zip
cpython-494181e44db809204f55eaebc88a255acb09a18f.tar.gz
cpython-494181e44db809204f55eaebc88a255acb09a18f.tar.bz2
[3.13] gh-93691: fix too broad source locations of with-statement instructions (GH-120125) (#123604)
gh-93691: fix too broad source locations of with-statement instructions (GH-120125) (cherry picked from commit eca3f7762c23b22a73a5e0b09520748c88aab4a0) Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/Python/compile.c b/Python/compile.c
index c331271..ed6923e 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -6036,7 +6036,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
/* Evaluate EXPR */
VISIT(c, expr, item->context_expr);
-
+ loc = LOC(item->context_expr);
ADDOP(c, loc, BEFORE_ASYNC_WITH);
ADDOP_I(c, loc, GET_AWAITABLE, 1);
ADDOP_LOAD_CONST(c, loc, Py_None);
@@ -6134,7 +6134,7 @@ compiler_with(struct compiler *c, stmt_ty s, int pos)
/* Evaluate EXPR */
VISIT(c, expr, item->context_expr);
/* Will push bound __exit__ */
- location loc = LOC(s);
+ location loc = LOC(item->context_expr);
ADDOP(c, loc, BEFORE_WITH);
ADDOP_JUMP(c, loc, SETUP_WITH, final);
@@ -6167,7 +6167,6 @@ compiler_with(struct compiler *c, stmt_ty s, int pos)
/* For successful outcome:
* call __exit__(None, None, None)
*/
- loc = LOC(s);
RETURN_IF_ERROR(compiler_call_exit_with_nones(c, loc));
ADDOP(c, loc, POP_TOP);
ADDOP_JUMP(c, loc, JUMP, exit);