diff options
author | Erlend E. Aasland <erlend.aasland@protonmail.com> | 2023-06-09 17:36:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-09 17:36:06 (GMT) |
commit | 90e357bc8a1cafa2ddbea98949e6f6a4d7d01475 (patch) | |
tree | d53aecef078e7858d81ab2153e86fdf077135f78 | |
parent | c28887d05900744e2ba40a2700e710c6f1beb93e (diff) | |
download | cpython-90e357bc8a1cafa2ddbea98949e6f6a4d7d01475.zip cpython-90e357bc8a1cafa2ddbea98949e6f6a4d7d01475.tar.gz cpython-90e357bc8a1cafa2ddbea98949e6f6a4d7d01475.tar.bz2 |
[3.11] gh-105375: Improve error handling in compiler_enter_scope() (#105494) (#105582)
(cherry picked from commit 6c832ddcf28187f86100c790afb16a0223d945d0)
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
-rw-r--r-- | Misc/NEWS.d/next/Core and Builtins/2023-06-08-09-54-37.gh-issue-105375.kqKT3E.rst | 1 | ||||
-rw-r--r-- | Python/compile.c | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/Misc/NEWS.d/next/Core and Builtins/2023-06-08-09-54-37.gh-issue-105375.kqKT3E.rst b/Misc/NEWS.d/next/Core and Builtins/2023-06-08-09-54-37.gh-issue-105375.kqKT3E.rst new file mode 100644 index 0000000..b4d3a1a --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2023-06-08-09-54-37.gh-issue-105375.kqKT3E.rst @@ -0,0 +1 @@ +Fix bug in the compiler where an exception could end up being overwritten. diff --git a/Python/compile.c b/Python/compile.c index 5f26da8..558df3f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -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 0; + } 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; } |