Skip to content
Merged
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
fixup! fixup! bpo-40619: Correctly handle error text and offset for <…
…string> input
  • Loading branch information
pablogsal committed May 14, 2020
commit 8a4ef9b167ec81ec8e42f773ace81d6bc024b6a2
7 changes: 4 additions & 3 deletions Parser/pegen/pegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,10 @@ _PyPegen_raise_error_known_location(Parser *p, PyObject *errtype,

if (!error_line) {
Py_ssize_t size = p->tok->inp - p->tok->buf;
error_line = PyUnicode_DecodeUTF8(p->tok->buf,
p->tok->buf[size-1] == '\n' ? size - 1 : size,
"replace");
if (size && p->tok->buf[size-1] == '\n') {
size--;
}
error_line = PyUnicode_DecodeUTF8(p->tok->buf, size, "replace");
if (!error_line) {
goto error;
}
Expand Down