mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-105375: Improve error handling in compiler_enter_scope() (#105494)
This commit is contained in:
parent
d7f46bcd98
commit
6c832ddcf2
2 changed files with 6 additions and 1 deletions
|
@ -0,0 +1 @@
|
||||||
|
Fix bug in the compiler where an exception could end up being overwritten.
|
|
@ -1228,8 +1228,12 @@ compiler_enter_scope(struct compiler *c, identifier name,
|
||||||
}
|
}
|
||||||
u->u_metadata.u_name = Py_NewRef(name);
|
u->u_metadata.u_name = Py_NewRef(name);
|
||||||
u->u_metadata.u_varnames = list2dict(u->u_ste->ste_varnames);
|
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);
|
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);
|
compiler_unit_free(u);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue