#define E_LINECONT 25 /* Unexpected characters after a line continuation */
#define E_IDENTIFIER 26 /* Invalid characters in identifier */
#define E_BADSINGLE 27 /* Ill-formed single statement input */
-#define E_BADPREFIX 28 /* Bad string prefixes */
#ifdef __cplusplus
}
"Bf''",
"BF''",]
double_quote_cases = [case.replace("'", '"') for case in single_quote_cases]
- self.assertAllRaise(SyntaxError, 'invalid string prefix',
+ self.assertAllRaise(SyntaxError, 'unexpected EOF while parsing',
single_quote_cases + double_quote_cases)
def test_leading_trailing_spaces(self):
--- /dev/null
+Reporting a specialised error message for invalid string prefixes, which was introduced in :issue:`40246`, is being reverted due to backwards compatibility concerns for strings that immediately follow a reserved keyword without whitespace between them. Constructs like `bg="#d00" if clear else"#fca"` were failing to parse, which is not an acceptable breakage on such short notice.
case E_IDENTIFIER:
msg = "invalid character in identifier";
break;
- case E_BADPREFIX:
- RAISE_SYNTAX_ERROR("invalid string prefix");
- return -1;
case E_EOFS:
RAISE_SYNTAX_ERROR("EOF while scanning triple-quoted string literal");
return -1;
*p_start = tok->start;
*p_end = tok->cur;
- if (c == '"' || c == '\'') {
- tok->done = E_BADPREFIX;
- return ERRORTOKEN;
- }
/* async/await parsing block. */
if (tok->cur - tok->start == 5 && tok->start[0] == 'a') {
/* May be an 'async' or 'await' token. For Python 3.7 or
case E_BADSINGLE:
msg = "multiple statements found while compiling a single statement";
break;
- case E_BADPREFIX:
- msg = "invalid string prefix";
- break;
default:
fprintf(stderr, "error=%d\n", err->error);
msg = "unknown parsing error";