diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2023-10-27 03:19:34 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-27 03:19:34 (GMT) |
commit | 3d2f1f0b830d86f16f42c42b54d3ea4453dac318 (patch) | |
tree | 384f6a750bf7cb49a3f73b9fe7080d24e3208587 /Parser/string_parser.c | |
parent | a254120f2f1dd99fa64f12594d1ed19c67df7d64 (diff) | |
download | cpython-3d2f1f0b830d86f16f42c42b54d3ea4453dac318.zip cpython-3d2f1f0b830d86f16f42c42b54d3ea4453dac318.tar.gz cpython-3d2f1f0b830d86f16f42c42b54d3ea4453dac318.tar.bz2 |
gh-111380: Show SyntaxWarnings only once when parsing if invalid syntax is encouintered (#111381)
Diffstat (limited to 'Parser/string_parser.c')
-rw-r--r-- | Parser/string_parser.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Parser/string_parser.c b/Parser/string_parser.c index f1e0277..bacfd81 100644 --- a/Parser/string_parser.c +++ b/Parser/string_parser.c @@ -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, |