[3.12] gh-105259: Ensure we don't show newline characters for trailing NEWLINE tokens (GH-105364) (#105367)

This commit is contained in:
Miss Islington (bot) 2023-06-06 05:47:45 -07:00 committed by GitHub
parent 6f3a4fd4f2
commit 67b288f8be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 5 deletions

View file

@ -243,10 +243,12 @@ tokenizeriter_next(tokenizeriterobject *it)
}
else if (type == NEWLINE) {
Py_DECREF(str);
if (it->tok->start[0] == '\r') {
str = PyUnicode_FromString("\r\n");
} else {
str = PyUnicode_FromString("\n");
if (!it->tok->implicit_newline) {
if (it->tok->start[0] == '\r') {
str = PyUnicode_FromString("\r\n");
} else {
str = PyUnicode_FromString("\n");
}
}
end_col_offset++;
}