Skip to content

Commit

Permalink
[3.12] gh-105375: Improve error handling in compiler_enter_scope() (G…
Browse files Browse the repository at this point in the history
…H-105494) (#105581)

(cherry picked from commit 6c832dd)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
  • Loading branch information
miss-islington and erlend-aasland committed Jun 9, 2023
1 parent bc365da commit 6540493
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
@@ -0,0 +1 @@
Fix bug in the compiler where an exception could end up being overwritten.
6 changes: 5 additions & 1 deletion Python/compile.c
Expand Up @@ -1252,8 +1252,12 @@ compiler_enter_scope(struct compiler *c, identifier name,
}
u->u_metadata.u_name = Py_NewRef(name);
u->u_metadata.u_varnames = list2dict(u->u_ste->ste_varnames);
if (!u->u_metadata.u_varnames) {
compiler_unit_free(u);
return ERROR;
}
u->u_metadata.u_cellvars = dictbytype(u->u_ste->ste_symbols, CELL, DEF_COMP_CELL, 0);
if (!u->u_metadata.u_varnames || !u->u_metadata.u_cellvars) {
if (!u->u_metadata.u_cellvars) {
compiler_unit_free(u);
return ERROR;
}
Expand Down

0 comments on commit 6540493

Please sign in to comment.