Make sure that line number is set correctly for call to __exit__ when handling exception in body of a with statement. (GH-26890)

This commit is contained in:
Mark Shannon 2021-06-24 15:12:48 +01:00 committed by GitHub
parent 599c07006a
commit 18ba1ff6a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 4526 additions and 4509 deletions

View file

@ -5053,6 +5053,7 @@ compiler_visit_keyword(struct compiler *c, keyword_ty k)
static int
compiler_with_except_finish(struct compiler *c, basicblock * cleanup) {
c->u->u_lineno = -1;
basicblock *exit;
exit = compiler_new_block(c);
if (exit == NULL)
@ -5168,7 +5169,6 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos)
/* For exceptional outcome: */
compiler_use_next_block(c, final);
c->u->u_lineno = -1;
ADDOP_JUMP(c, SETUP_CLEANUP, cleanup);
ADDOP(c, PUSH_EXC_INFO);
@ -5265,7 +5265,6 @@ compiler_with(struct compiler *c, stmt_ty s, int pos)
/* For exceptional outcome: */
compiler_use_next_block(c, final);
c->u->u_lineno = -1;
ADDOP_JUMP(c, SETUP_CLEANUP, cleanup);
ADDOP(c, PUSH_EXC_INFO);