Skip to content

Commit

Permalink
Fix line number in error message
Browse files Browse the repository at this point in the history
  • Loading branch information
mdboom committed Aug 31, 2022
1 parent f741a9d commit f8e9e6e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Lib/test/test_source_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f8e9e6e

Please sign in to comment.