gh-130139: always check ast node type in ast.parse() with ast input (#130140)

This commit is contained in:
Irit Katriel 2025-02-16 13:32:39 +00:00 committed by GitHub
parent 2e8044a4f7
commit c9b1bf302c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 73 additions and 32 deletions

View file

@ -835,6 +835,9 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
goto error;
if (is_ast) {
if ((flags & PyCF_OPTIMIZED_AST) == PyCF_ONLY_AST) {
if (PyAst_CheckMode(source, compile_mode) < 0) {
goto error;
}
// return an un-optimized AST
result = Py_NewRef(source);
}