[3.12] gh-93691: fix too broad source locations of with-statement instructions (GH-120125) (#123605)

gh-93691: fix too broad source locations of with-statement instructions (GH-120125)
(cherry picked from commit eca3f7762c)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-09-02 16:45:09 +02:00 committed by GitHub
parent d47d7e1124
commit 22ec9cb823
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 47 additions and 3 deletions

View file

@ -5913,7 +5913,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);
@ -6011,7 +6011,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);
@ -6044,7 +6044,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);