summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2020-06-20 16:55:08 -0700
committerGuido van Rossum <guido@python.org>2020-06-20 16:55:08 -0700
commit12c3135d6d72da0267c139b0a62fdca437a92d5b (patch)
treecc5bec3b47c10e2ed4f239e29ab59d5530c7bc8c
parent3ccb96c9782480e5ce646a4a130569fb92f2965d (diff)
downloadcpython-git-fix-cf-feature-versiob.tar.gz
Only use cf_feature_version if PyCF_ONLY_AST in cf_flagsfix-cf-feature-versiob
-rw-r--r--Parser/pegen.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c
index 594754cee5..b7db09f438 100644
--- a/Parser/pegen.c
+++ b/Parser/pegen.c
@@ -1018,7 +1018,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;
@@ -1191,7 +1191,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) {