summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2020-06-28 00:34:30 (GMT)
committerGitHub <noreply@github.com>2020-06-28 00:34:30 (GMT)
commit2a1ee1d970460047bd88da9638f8c1789431d9ab (patch)
treef9d788be367da763dc8d712b78aa5005c3d0dd35 /Parser
parentdab533d0ee067159812d4ea51f6fbbb1bd37d8b7 (diff)
downloadcpython-2a1ee1d970460047bd88da9638f8c1789431d9ab.zip
cpython-2a1ee1d970460047bd88da9638f8c1789431d9ab.tar.gz
cpython-2a1ee1d970460047bd88da9638f8c1789431d9ab.tar.bz2
[3.9] bpo-35975: Only use cf_feature_version if PyCF_ONLY_AST in cf_flags (#21022)
Diffstat (limited to 'Parser')
-rw-r--r--Parser/pegen/pegen.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Parser/pegen/pegen.c b/Parser/pegen/pegen.c
index ef48ade..895677b 100644
--- a/Parser/pegen/pegen.c
+++ b/Parser/pegen/pegen.c
@@ -1041,7 +1041,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;
@@ -1214,7 +1214,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) {