diff options
author | Eric V. Smith <ericvsmith@users.noreply.github.com> | 2022-02-16 10:54:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-16 10:54:09 (GMT) |
commit | ffd9f8ff84ed53c956b16d027f7d2926ea631051 (patch) | |
tree | 2fa671996d72b409743db26ddf247a8045812c20 /Parser/string_parser.c | |
parent | e59309b9d0969d5c8f493cb8df28afa6f38d6273 (diff) | |
download | cpython-ffd9f8ff84ed53c956b16d027f7d2926ea631051.zip cpython-ffd9f8ff84ed53c956b16d027f7d2926ea631051.tar.gz cpython-ffd9f8ff84ed53c956b16d027f7d2926ea631051.tar.bz2 |
bpo-46762: Fix an assert failure in f-strings where > or < is the last character if the f-string is missing a trailing right brace. (#31365)
Diffstat (limited to 'Parser/string_parser.c')
-rw-r--r-- | Parser/string_parser.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Parser/string_parser.c b/Parser/string_parser.c index 0b5e30b..fae2a36 100644 --- a/Parser/string_parser.c +++ b/Parser/string_parser.c @@ -666,12 +666,12 @@ fstring_find_expr(Parser *p, const char **str, const char *end, int raw, int rec *str += 1; continue; } - /* Don't get out of the loop for these, if they're single - chars (not part of 2-char tokens). If by themselves, they - don't end an expression (unlike say '!'). */ - if (ch == '>' || ch == '<') { - continue; - } + } + /* Don't get out of the loop for these, if they're single + chars (not part of 2-char tokens). If by themselves, they + don't end an expression (unlike say '!'). */ + if (ch == '>' || ch == '<') { + continue; } /* Normal way out of this loop. */ @@ -698,10 +698,10 @@ fstring_find_expr(Parser *p, const char **str, const char *end, int raw, int rec } } expr_end = *str; - /* If we leave this loop in a string or with mismatched parens, we - don't care. We'll get a syntax error when compiling the - expression. But, we can produce a better error message, so - let's just do that.*/ + /* If we leave the above loop in a string or with mismatched parens, we + don't really care. We'll get a syntax error when compiling the + expression. But, we can produce a better error message, so let's just + do that.*/ if (quote_char) { RAISE_SYNTAX_ERROR("f-string: unterminated string"); goto error; |