Crash report
What happened?
Minimal repro:
print("Reproducing!")
exec("", closure=object())
Fails with
Reproducing!
python: Python/ast.c:1047: _PyAST_Validate: Assertion `!PyErr_Occurred()' failed.
Aborted (core dumped)
Note the error occurs not because the passed closure= is incorrect (it should be a tuple of cell objects), but because closure= is not allowed when string is the source.
The reason for that to happen is a missing goto error jump:
|
if (closure != NULL) { |
|
PyErr_SetString(PyExc_TypeError, |
|
"closure can only be used when source is a code object"); |
|
} |
causing the rest of the code to execute and reach _PyAST_Validate.
In the PR, I included the missing test case.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0a5+ (heads/main-dirty:f9a7d41bacb, Feb 13 2025, 04:52:15) [GCC 11.4.0]
Linked PRs
Crash report
What happened?
Minimal repro:
Fails with
Note the error occurs not because the passed
closure=is incorrect (it should be a tuple of cell objects), but becauseclosure=is not allowed when string is the source.The reason for that to happen is a missing
goto errorjump:cpython/Python/bltinmodule.c
Lines 1175 to 1178 in 2a0256f
causing the rest of the code to execute and reach
_PyAST_Validate.In the PR, I included the missing test case.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0a5+ (heads/main-dirty:f9a7d41bacb, Feb 13 2025, 04:52:15) [GCC 11.4.0]
Linked PRs
exec(<string>, closure=<non-None>)unexpected path #130071exec(<string>, closure=<non-None>)unexpected path (GH-130071) #132627