summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorShantanu <hauntsaninja@users.noreply.github.com>2020-05-27 20:30:38 (GMT)
committerGitHub <noreply@github.com>2020-05-27 20:30:38 (GMT)
commitc116c94ff119485761460f1033cdee425bed0310 (patch)
tree83d645e05d244b3692c004648a510691a4856a96 /Parser
parentdb5aed931f8a617f7b63e773f62db468fe9c5ca1 (diff)
downloadcpython-c116c94ff119485761460f1033cdee425bed0310.zip
cpython-c116c94ff119485761460f1033cdee425bed0310.tar.gz
cpython-c116c94ff119485761460f1033cdee425bed0310.tar.bz2
bpo-40614: Respect feature version for f-string debug expressions (GH-20196)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Diffstat (limited to 'Parser')
-rw-r--r--Parser/pegen/parse_string.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Parser/pegen/parse_string.c b/Parser/pegen/parse_string.c
index a0ec698..e24ecc5 100644
--- a/Parser/pegen/parse_string.c
+++ b/Parser/pegen/parse_string.c
@@ -928,6 +928,11 @@ fstring_find_expr(Parser *p, const char **str, const char *end, int raw, int rec
/* Check for =, which puts the text value of the expression in
expr_text. */
if (**str == '=') {
+ if (p->feature_version < 8) {
+ RAISE_SYNTAX_ERROR("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