Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
("t'{lambda:1}'", "t-string: lambda expressions are not allowed "
"without parentheses"),
("t'{x:{;}}'", "t-string: expecting a valid expression after '{'"),
+ ("t'{1:d\n}'", "t-string: newlines are not allowed in format specifiers")
):
with self.subTest(case), self.assertRaisesRegex(SyntaxError, err):
eval(case)
--- /dev/null
+Differentiate between t-strings and f-strings in syntax error for newlines
+in format specifiers of single-quoted interpolated strings.
return MAKE_TOKEN(
_PyTokenizer_syntaxerror(
tok,
- "f-string: newlines are not allowed in format specifiers for single quoted f-strings"
+ "%c-string: newlines are not allowed in format specifiers for single quoted %c-strings",
+ TOK_GET_STRING_PREFIX(tok), TOK_GET_STRING_PREFIX(tok)
)
);
}