mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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>
This commit is contained in:
parent
15ba8167d7
commit
7b44ade018
3 changed files with 35 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue