Skip to content

Commit

Permalink
[3.11] pythongh-105375: Improve error handling in compiler_enter_scop…
Browse files Browse the repository at this point in the history
…e() (python#105494)
  • Loading branch information
erlend-aasland committed Jun 9, 2023
1 parent c28887d commit 73d4a26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -1736,8 +1736,12 @@ compiler_enter_scope(struct compiler *c, identifier name,
Py_INCREF(name);
u->u_name = name;
u->u_varnames = list2dict(u->u_ste->ste_varnames);
if (!u->u_varnames) {
compiler_unit_free(u);
return ERROR;
}
u->u_cellvars = dictbytype(u->u_ste->ste_symbols, CELL, 0, 0);
if (!u->u_varnames || !u->u_cellvars) {
if (!u->u_cellvars) {
compiler_unit_free(u);
return 0;
}
Expand Down

0 comments on commit 73d4a26

Please sign in to comment.