aboutsummaryrefslogtreecommitdiff
path: root/Parser
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2020-06-27 17:33:49 -0700
committerGitHub <noreply@github.com>2020-06-27 17:33:49 -0700
commit9d197c7d48147a9ea2f7f7be917f35514a16524b (patch)
tree1b8f059794d4b1c1daa2a37a2799d68230f53a65 /Parser
parentbpo-41076: Pre-feed the parser with the f-string expression location (GH-21054) (diff)
downloadcpython-9d197c7d48147a9ea2f7f7be917f35514a16524b.tar.gz
cpython-9d197c7d48147a9ea2f7f7be917f35514a16524b.tar.bz2
cpython-9d197c7d48147a9ea2f7f7be917f35514a16524b.zip
bpo-35975: Only use cf_feature_version if PyCF_ONLY_AST in cf_flags (#21021)
Diffstat (limited to 'Parser')
-rw-r--r--Parser/pegen.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c
index 19762b06d3c..53e3d491383 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) {