summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-06-06 12:47:45 (GMT)
committerGitHub <noreply@github.com>2023-06-06 12:47:45 (GMT)
commit67b288f8be4989176ffab04c72794e5faf5797a5 (patch)
tree3b448dc8c05f72afce7b4b407d9568f5568b0fba /Python
parent6f3a4fd4f23f8013cca5abdf03bcc7dd4adf8637 (diff)
downloadcpython-67b288f8be4989176ffab04c72794e5faf5797a5.zip
cpython-67b288f8be4989176ffab04c72794e5faf5797a5.tar.gz
cpython-67b288f8be4989176ffab04c72794e5faf5797a5.tar.bz2
[3.12] gh-105259: Ensure we don't show newline characters for trailing NEWLINE tokens (GH-105364) (#105367)
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-tokenize.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Python/Python-tokenize.c b/Python/Python-tokenize.c
index a7933b2..223de54 100644
--- a/Python/Python-tokenize.c
+++ b/Python/Python-tokenize.c
@@ -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++;
}