Skip to content

Commit 6c832dd

Browse files
gh-105375: Improve error handling in compiler_enter_scope() (#105494)
1 parent d7f46bc commit 6c832dd

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug in the compiler where an exception could end up being overwritten.

Python/compile.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -1228,8 +1228,12 @@ compiler_enter_scope(struct compiler *c, identifier name,
12281228
}
12291229
u->u_metadata.u_name = Py_NewRef(name);
12301230
u->u_metadata.u_varnames = list2dict(u->u_ste->ste_varnames);
1231+
if (!u->u_metadata.u_varnames) {
1232+
compiler_unit_free(u);
1233+
return ERROR;
1234+
}
12311235
u->u_metadata.u_cellvars = dictbytype(u->u_ste->ste_symbols, CELL, DEF_COMP_CELL, 0);
1232-
if (!u->u_metadata.u_varnames || !u->u_metadata.u_cellvars) {
1236+
if (!u->u_metadata.u_cellvars) {
12331237
compiler_unit_free(u);
12341238
return ERROR;
12351239
}

0 commit comments

Comments
 (0)