diff options
author | Maciej Górski <36813763+macgors@users.noreply.github.com> | 2022-03-28 21:08:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-28 21:08:36 (GMT) |
commit | 7b44ade018cfe6f54002a3cee43e8aa415d4d635 (patch) | |
tree | 07816d9022fea4b902b69026360d912167410daf /Parser | |
parent | 15ba8167d78f9e66bd5b07c4e5cbb0463460310a (diff) | |
download | cpython-7b44ade018cfe6f54002a3cee43e8aa415d4d635.zip cpython-7b44ade018cfe6f54002a3cee43e8aa415d4d635.tar.gz cpython-7b44ade018cfe6f54002a3cee43e8aa415d4d635.tar.bz2 |
bpo-47129: Add more informative messages to f-string syntax errors (32127)
* Add more informative messages to f-string syntax errors
* 📜🤖 Added by blurb_it.
* Fix whitespaces
* Change error message
* Remove the 'else' statement (as sugested in review)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/string_parser.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Parser/string_parser.c b/Parser/string_parser.c index fae2a36..65ddd46 100644 --- a/Parser/string_parser.c +++ b/Parser/string_parser.c @@ -357,7 +357,12 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end, break; } } + if (s == expr_end) { + if (*expr_end == '!' || *expr_end == ':' || *expr_end == '=') { + RAISE_SYNTAX_ERROR("f-string: expression required before '%c'", *expr_end); + return NULL; + } RAISE_SYNTAX_ERROR("f-string: empty expression not allowed"); return NULL; } |