[3.12] gh-105375: Improve error handling in compiler_enter_scope() (GH-105494) (#105581)

(cherry picked from commit 6c832ddcf2)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
Miss Islington (bot) 2023-06-09 10:23:45 -07:00 committed by GitHub
parent bc365da711
commit 65404930bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -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;
}