mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Generate code to recursively copy an AST into
a tree of Python objects. Expose this through compile().
This commit is contained in:
parent
23b0dc5053
commit
bd260da900
8 changed files with 1906 additions and 745 deletions
2196
Python/Python-ast.c
2196
Python/Python-ast.c
File diff suppressed because it is too large
Load diff
|
@ -443,7 +443,7 @@ builtin_compile(PyObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
if (supplied_flags &
|
||||
~(PyCF_MASK | PyCF_MASK_OBSOLETE | PyCF_DONT_IMPLY_DEDENT))
|
||||
~(PyCF_MASK | PyCF_MASK_OBSOLETE | PyCF_DONT_IMPLY_DEDENT | PyCF_ONLY_AST))
|
||||
{
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"compile(): unrecognised flags");
|
||||
|
|
|
@ -1254,6 +1254,11 @@ Py_CompileStringFlags(const char *str, const char *filename, int start,
|
|||
PyArena_Free(arena);
|
||||
return NULL;
|
||||
}
|
||||
if (flags->cf_flags & PyCF_ONLY_AST) {
|
||||
PyObject *result = PyAST_mod2obj(mod);
|
||||
PyArena_Free(arena);
|
||||
return result;
|
||||
}
|
||||
co = PyAST_Compile(mod, filename, flags, arena);
|
||||
PyArena_Free(arena);
|
||||
return (PyObject *)co;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue