gh-129958: Properly disallow newlines in format specs in single-quoted f-strings (GH-130063)
This commit is contained in:
committed by
GitHub
parent
e01e582902
commit
2f8b08da47
@@ -1341,6 +1341,14 @@ f_string_middle:
|
||||
// it means that the format spec ends here and we should
|
||||
// return to the regular mode.
|
||||
if (in_format_spec && c == '\n') {
|
||||
if (current_tok->f_string_quote_size == 1) {
|
||||
return MAKE_TOKEN(
|
||||
_PyTokenizer_syntaxerror(
|
||||
tok,
|
||||
"f-string: newlines are not allowed in format specifiers for single quoted f-strings"
|
||||
)
|
||||
);
|
||||
}
|
||||
tok_backup(tok, c);
|
||||
TOK_GET_MODE(tok)->kind = TOK_REGULAR_MODE;
|
||||
current_tok->in_format_spec = 0;
|
||||
|
||||
Reference in New Issue
Block a user