gh-130070: Fix exec(<string>, closure=<non-None>) unexpected path (#130071)

Fixed an assertion error (so, it could be reproduced only in builds with assertions enabled)
for `exec` when the `source` argument is a string and the `closure` argument is not `None`.

Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
Bartosz Sławecki 2025-04-17 09:14:55 +02:00 committed by GitHub
parent d7df7815f5
commit 954b2cf031
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 0 deletions

View file

@ -1169,6 +1169,7 @@ builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals,
if (closure != NULL) {
PyErr_SetString(PyExc_TypeError,
"closure can only be used when source is a code object");
goto error;
}
PyObject *source_copy;
const char *str;