Commit 832bfe2e authored by Benjamin Peterson's avatar Benjamin Peterson

add a AST validator (closes #12575)

parent 450bb594
......@@ -4,6 +4,7 @@
extern "C" {
#endif
PyAPI_FUNC(int) PyAST_Validate(mod_ty);
PyAPI_FUNC(mod_ty) PyAST_FromNode(
const node *n,
PyCompilerFlags *flags,
......
This diff is collapsed.
......@@ -10,6 +10,8 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins
-----------------
- Issue #12575: Validate user-generated AST before it is compiled.
- Make type(None), type(Ellipsis), and type(NotImplemented) callable. They
return the respective singleton instances.
......
This diff is collapsed.
......@@ -604,6 +604,10 @@ builtin_compile(PyObject *self, PyObject *args, PyObject *kwds)
PyArena_Free(arena);
goto error;
}
if (!PyAST_Validate(mod)) {
PyArena_Free(arena);
goto error;
}
result = (PyObject*)PyAST_CompileEx(mod, filename,
&cf, optimize, arena);
PyArena_Free(arena);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment