summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2023-06-06 11:52:16 (GMT)
committerGitHub <noreply@github.com>2023-06-06 11:52:16 (GMT)
commitc0a6ed39343b6dc355607fbff108c515e6c103bf (patch)
tree39b12fa4a80178944cba90020076b336f4c9f1f4 /Python
parent0202aa002e06acef9aa55ace0d939103df19cadd (diff)
downloadcpython-c0a6ed39343b6dc355607fbff108c515e6c103bf.zip
cpython-c0a6ed39343b6dc355607fbff108c515e6c103bf.tar.gz
cpython-c0a6ed39343b6dc355607fbff108c515e6c103bf.tar.bz2
gh-105259: Ensure we don't show newline characters for trailing NEWLINE tokens (#105364)
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++;
}