mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
gh-111380: Show SyntaxWarnings only once when parsing if invalid syntax is encouintered (#111381)
This commit is contained in:
parent
a254120f2f
commit
3d2f1f0b83
3 changed files with 19 additions and 0 deletions
|
@ -13,6 +13,11 @@
|
|||
static int
|
||||
warn_invalid_escape_sequence(Parser *p, const char *first_invalid_escape, Token *t)
|
||||
{
|
||||
if (p->call_invalid_rules) {
|
||||
// Do not report warnings if we are in the second pass of the parser
|
||||
// to avoid showing the warning twice.
|
||||
return 0;
|
||||
}
|
||||
unsigned char c = *first_invalid_escape;
|
||||
if ((t->type == FSTRING_MIDDLE || t->type == FSTRING_END) && (c == '{' || c == '}')) {
|
||||
// in this case the tokenizer has already emitted a warning,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue