summaryrefslogtreecommitdiffstats
path: root/Parser/string_parser.c
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2023-10-27 03:19:34 (GMT)
committerGitHub <noreply@github.com>2023-10-27 03:19:34 (GMT)
commit3d2f1f0b830d86f16f42c42b54d3ea4453dac318 (patch)
tree384f6a750bf7cb49a3f73b9fe7080d24e3208587 /Parser/string_parser.c
parenta254120f2f1dd99fa64f12594d1ed19c67df7d64 (diff)
downloadcpython-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.c5
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,