mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
gh-104972: Ensure that line attributes in tokens in the tokenize module are correct (#104975)
This commit is contained in:
parent
2cb445635e
commit
3fdb55c482
4 changed files with 21 additions and 9 deletions
|
@ -194,15 +194,14 @@ tokenizeriter_next(tokenizeriterobject *it)
|
|||
goto exit;
|
||||
}
|
||||
|
||||
Py_ssize_t size = it->tok->inp - it->tok->buf;
|
||||
assert(it->tok->buf[size-1] == '\n');
|
||||
size -= 1; // Remove the newline character from the end of the line
|
||||
PyObject *line = PyUnicode_DecodeUTF8(it->tok->buf, size, "replace");
|
||||
const char *line_start = ISSTRINGLIT(type) ? it->tok->multi_line_start : it->tok->line_start;
|
||||
Py_ssize_t size = it->tok->inp - line_start;
|
||||
PyObject *line = PyUnicode_DecodeUTF8(line_start, size, "replace");
|
||||
if (line == NULL) {
|
||||
Py_DECREF(str);
|
||||
goto exit;
|
||||
}
|
||||
const char *line_start = ISSTRINGLIT(type) ? it->tok->multi_line_start : it->tok->line_start;
|
||||
|
||||
Py_ssize_t lineno = ISSTRINGLIT(type) ? it->tok->first_lineno : it->tok->lineno;
|
||||
Py_ssize_t end_lineno = it->tok->lineno;
|
||||
Py_ssize_t col_offset = -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue