Skip to content

Commit f8e9e6e

Browse files
committed
Fix line number in error message
1 parent f741a9d commit f8e9e6e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Lib/test/test_source_encoding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def check(content):
252252
# not via a signal.
253253
self.assertGreaterEqual(rc, 1)
254254
self.assertIn(b"Non-UTF-8 code starting with", stderr)
255-
self.assertIn(b"on line 5", stderr)
255+
self.assertIn(b"on line 4", stderr)
256256

257257
# continuation bytes in a sequence of 2, 3, or 4 bytes
258258
continuation_bytes = [bytes([x]) for x in range(0x80, 0xC0)]

Parser/tokenizer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ ensure_utf8(char *line, struct tok_state *tok)
564564
"in file %U on line %i, "
565565
"but no encoding declared; "
566566
"see https://peps.python.org/pep-0263/ for details",
567-
badchar, tok->filename, tok->lineno + 1);
567+
badchar, tok->filename, tok->lineno);
568568
return 0;
569569
}
570570
return 1;

0 commit comments

Comments
 (0)