diff --git a/Lib/test/test_source_encoding.py b/Lib/test/test_source_encoding.py index 6d0e9a50df9344..1c39f53c6c3676 100644 --- a/Lib/test/test_source_encoding.py +++ b/Lib/test/test_source_encoding.py @@ -252,7 +252,7 @@ def check(content): # not via a signal. self.assertGreaterEqual(rc, 1) self.assertIn(b"Non-UTF-8 code starting with", stderr) - self.assertIn(b"on line 5", stderr) + self.assertIn(b"on line 4", stderr) # continuation bytes in a sequence of 2, 3, or 4 bytes continuation_bytes = [bytes([x]) for x in range(0x80, 0xC0)] diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 381c2fe414eabb..f3ab1d446e17f7 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -564,7 +564,7 @@ ensure_utf8(char *line, struct tok_state *tok) "in file %U on line %i, " "but no encoding declared; " "see https://peps.python.org/pep-0263/ for details", - badchar, tok->filename, tok->lineno + 1); + badchar, tok->filename, tok->lineno); return 0; } return 1;