[New-bugs-announce] [issue40863] bytes.decode changes/destroys line endings on windows

Matthias Naegler report at bugs.python.org
Thu Jun 4 10:07:03 EDT 2020


New submission from Matthias Naegler <matthias.naegler at gmail.com>:

```
# 0x0D, 13 = /r
# 0x0A, 10 = /n

print('test "\\r\\n"')
print('-------------')
b = bytes([0x41, 0x0D, 0x0A])
print("bytes: %s" % b)
print("string: %s" % b.decode('utf8'), end='')
# expected string: "A\r\n"
# ressult string: "A\r\r\n"

print('test "\\n"')
print('----------')
b = bytes([0x41, 0x0A])
print("bytes: %s" % b)
print("string: %s" % b.decode('utf8'), end='')
# expected string: "A\n"
# ressult string: "A\r\n"
```

It seems like bytes.decode always replaces "\n" with "\r\n".

Tested with
Windows 10 with Python:
- 3.6.0
- 3.7.7
- 3.8.3-rc1
- 3.8.3
- 2.7.18 (works as expected)

----------
components: Unicode, Windows
messages: 370711
nosy: Matthias Naegler, ezio.melotti, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
priority: normal
severity: normal
status: open
title: bytes.decode changes/destroys line endings on windows
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40863>
_______________________________________


More information about the New-bugs-announce mailing list