Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bc28805

Browse files
authored
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
1 parent 40ded94 commit bc28805

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Python/bltinmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ builtin_compile_impl(PyObject *module, PyObject *source, PyObject *filename,
817817
goto error;
818818

819819
int current_use_peg = PyInterpreterState_Get()->config._use_peg_parser;
820-
if (flags & PyCF_TYPE_COMMENTS || feature_version >= 0) {
820+
if (flags & PyCF_TYPE_COMMENTS || feature_version >= 0 || compile_mode == 3) {
821821
PyInterpreterState_Get()->config._use_peg_parser = 0;
822822
}
823823
result = Py_CompileStringObject(str, filename, start[compile_mode], &cf, optimize);

0 commit comments

Comments
 (0)