summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2019-01-31 11:40:27 (GMT)
committerƁukasz Langa <lukasz@langa.pl>2019-01-31 11:40:27 (GMT)
commitdcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c (patch)
tree07829c4f286194d0e3d08151a26ef1f3494a849b /Python/bltinmodule.c
parentd97daebfa69b4df95231bcae4123eacad6a48d14 (diff)
downloadcpython-dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c.zip
cpython-dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c.tar.gz
cpython-dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c.tar.bz2
bpo-35766: Merge typed_ast back into CPython (GH-11645)
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 332142f..f9b901f 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -765,13 +765,13 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
int compile_mode = -1;
int is_ast;
PyCompilerFlags cf;
- int start[] = {Py_file_input, Py_eval_input, Py_single_input};
+ int start[] = {Py_file_input, Py_eval_input, Py_single_input, Py_func_type_input};
PyObject *result;
cf.cf_flags = flags | PyCF_SOURCE_IS_UTF8;
if (flags &
- ~(PyCF_MASK | PyCF_MASK_OBSOLETE | PyCF_DONT_IMPLY_DEDENT | PyCF_ONLY_AST))
+ ~(PyCF_MASK | PyCF_MASK_OBSOLETE | PyCF_DONT_IMPLY_DEDENT | PyCF_ONLY_AST | PyCF_TYPE_COMMENTS))
{
PyErr_SetString(PyExc_ValueError,
"compile(): unrecognised flags");
@@ -795,9 +795,21 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
compile_mode = 1;
else if (strcmp(mode, "single") == 0)
compile_mode = 2;
+ else if (strcmp(mode, "func_type") == 0) {
+ if (!(flags & PyCF_ONLY_AST)) {
+ PyErr_SetString(PyExc_ValueError,
+ "compile() mode 'func_type' requires flag PyCF_ONLY_AST");
+ goto error;
+ }
+ compile_mode = 3;
+ }
else {
- PyErr_SetString(PyExc_ValueError,
- "compile() mode must be 'exec', 'eval' or 'single'");
+ const char *msg;
+ if (flags & PyCF_ONLY_AST)
+ msg = "compile() mode must be 'exec', 'eval', 'single' or 'func_type'";
+ else
+ msg = "compile() mode must be 'exec', 'eval' or 'single'";
+ PyErr_SetString(PyExc_ValueError, msg);
goto error;
}