From c116c94ff119485761460f1033cdee425bed0310 Mon Sep 17 00:00:00 2001 From: Shantanu Date: Wed, 27 May 2020 13:30:38 -0700 Subject: bpo-40614: Respect feature version for f-string debug expressions (GH-20196) Co-authored-by: Lysandros Nikolaou Co-authored-by: Pablo Galindo --- Python/ast.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Python/ast.c') diff --git a/Python/ast.c b/Python/ast.c index 2d20ca62aa..c524b8e34e 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -5069,6 +5069,12 @@ fstring_find_expr(const char **str, const char *end, int raw, int recurse_lvl, /* Check for =, which puts the text value of the expression in expr_text. */ if (**str == '=') { + if (c->c_feature_version < 8) { + ast_error(c, n, + "f-string: self documenting expressions are " + "only supported in Python 3.8 and greater"); + goto error; + } *str += 1; /* Skip over ASCII whitespace. No need to test for end of string -- cgit v1.2.1