diff options
author | Guido van Rossum <guido@python.org> | 2020-04-23 15:42:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-23 15:42:56 -0700 |
commit | bc28805570ae3e8835a5d502ae9ab15c52449f77 (patch) | |
tree | 50fcd3677bde21955ccbf524b41e74fada76f58d | |
parent | 40ded947f82683f0ed08144599a83d3a1ce719eb (diff) | |
download | cpython-git-bc28805570ae3e8835a5d502ae9ab15c52449f77.tar.gz |
bpo-40334: Use old compiler when compile mode is func_type (GH-19692)
This is invoked by mypy, using ast.parse(source, "<func_type>", "func_type"). Since the new grammar doesn't yet support the func_type_input start symbol we must use the old compiler in this case to prevent a crash.
https://bugs.python.org/issue40334
-rw-r--r-- | Python/bltinmodule.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index ce3561e4c0..14c3e96fb5 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -817,7 +817,7 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename, goto error; int current_use_peg = PyInterpreterState_Get()->config._use_peg_parser; - if (flags & PyCF_TYPE_COMMENTS || feature_version >= 0) { + if (flags & PyCF_TYPE_COMMENTS || feature_version >= 0 || compile_mode == 3) { PyInterpreterState_Get()->config._use_peg_parser = 0; } result = Py_CompileStringObject(str, filename, start[compile_mode], &cf, optimize); |