diff options
author | Guido van Rossum <guido@python.org> | 2020-06-28 00:33:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-28 00:33:49 (GMT) |
commit | 9d197c7d48147a9ea2f7f7be917f35514a16524b (patch) | |
tree | 1b8f059794d4b1c1daa2a37a2799d68230f53a65 /Parser | |
parent | 1f0f4abb110b9fbade6175842b6a26ab0b8df6dd (diff) | |
download | cpython-9d197c7d48147a9ea2f7f7be917f35514a16524b.zip cpython-9d197c7d48147a9ea2f7f7be917f35514a16524b.tar.gz cpython-9d197c7d48147a9ea2f7f7be917f35514a16524b.tar.bz2 |
bpo-35975: Only use cf_feature_version if PyCF_ONLY_AST in cf_flags (#21021)
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/pegen.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c index 19762b0..53e3d49 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -1042,7 +1042,7 @@ compute_parser_flags(PyCompilerFlags *flags) if (flags->cf_flags & PyCF_TYPE_COMMENTS) { parser_flags |= PyPARSE_TYPE_COMMENTS; } - if (flags->cf_feature_version < 7) { + if ((flags->cf_flags & PyCF_ONLY_AST) && flags->cf_feature_version < 7) { parser_flags |= PyPARSE_ASYNC_HACKS; } return parser_flags; @@ -1215,7 +1215,8 @@ _PyPegen_run_parser_from_string(const char *str, int start_rule, PyObject *filen mod_ty result = NULL; int parser_flags = compute_parser_flags(flags); - int feature_version = flags ? flags->cf_feature_version : PY_MINOR_VERSION; + int feature_version = flags && (flags->cf_flags & PyCF_ONLY_AST) ? + flags->cf_feature_version : PY_MINOR_VERSION; Parser *p = _PyPegen_Parser_New(tok, start_rule, parser_flags, feature_version, NULL, arena); if (p == NULL) { |