Visitar URL original
gh-96268: Fix loading invalid UTF-8 by mdboom · Pull Request #96270 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix line number in error message
  • Loading branch information
mdboom committed Aug 31, 2022
commit f8e9e6eb33ff4695b64c77fb8740553ff7ce67d4
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