summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend.aasland@protonmail.com>2023-06-09 16:55:53 (GMT)
committerGitHub <noreply@github.com>2023-06-09 16:55:53 (GMT)
commit6c832ddcf28187f86100c790afb16a0223d945d0 (patch)
tree3e14bfd84d0a54a9c1c4c505c75969211acd4eac /Python/compile.c
parentd7f46bcd989580340675bf0a9fdbfa1505a37e81 (diff)
downloadcpython-6c832ddcf28187f86100c790afb16a0223d945d0.zip
cpython-6c832ddcf28187f86100c790afb16a0223d945d0.tar.gz
cpython-6c832ddcf28187f86100c790afb16a0223d945d0.tar.bz2
gh-105375: Improve error handling in compiler_enter_scope() (#105494)
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 3243172..e3a7623 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1228,8 +1228,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;
}