mirror of
https://github.com/python/cpython.git
synced 2025-07-10 04:45:36 +00:00
[3.12] gh-105435: Fix spurious NEWLINE token if file ends with comment without a newline (GH-105442) (#105444)
This commit is contained in:
parent
bb6ea72003
commit
117c153d9f
3 changed files with 39 additions and 5 deletions
|
@ -247,6 +247,17 @@ tokenizeriter_next(tokenizeriterobject *it)
|
|||
}
|
||||
end_col_offset++;
|
||||
}
|
||||
else if (type == NL) {
|
||||
if (it->tok->implicit_newline) {
|
||||
Py_DECREF(str);
|
||||
str = PyUnicode_FromString("");
|
||||
}
|
||||
}
|
||||
|
||||
if (str == NULL) {
|
||||
Py_DECREF(line);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
result = Py_BuildValue("(iN(nn)(nn)N)", type, str, lineno, col_offset, end_lineno, end_col_offset, line);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue