summaryrefslogtreecommitdiff
path: root/Parser/pegen/parse_string.c
diff options
context:
space:
mode:
Diffstat (limited to 'Parser/pegen/parse_string.c')
-rw-r--r--Parser/pegen/parse_string.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Parser/pegen/parse_string.c b/Parser/pegen/parse_string.c
index 834239e23f..d96303dc18 100644
--- a/Parser/pegen/parse_string.c
+++ b/Parser/pegen/parse_string.c
@@ -179,6 +179,13 @@ _PyPegen_parsestr(Parser *p, const char *s, int *bytesmode, int *rawmode, PyObje
}
}
+ /* fstrings are only allowed in Python 3.6 and greater */
+ if (fmode && p->feature_version < 6) {
+ p->error_indicator = 1;
+ RAISE_SYNTAX_ERROR("Format strings are only supported in Python 3.6 and greater");
+ return -1;
+ }
+
if (fmode && *bytesmode) {
PyErr_BadInternalCall();
return -1;
@@ -595,7 +602,8 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
return NULL;
}
- Parser *p2 = _PyPegen_Parser_New(tok, Py_fstring_input, p->flags, NULL, p->arena);
+ Parser *p2 = _PyPegen_Parser_New(tok, Py_fstring_input, p->flags, p->feature_version,
+ NULL, p->arena);
p2->starting_lineno = p->starting_lineno + p->tok->first_lineno - 1;
p2->starting_col_offset = p->tok->first_lineno == p->tok->lineno
? p->starting_col_offset + t->col_offset : 0;