Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
You don't need `b = bytes([0x41, 0x0D, 0x0A])`, this will work just as well: b = b'\x41\x0D\x0A' and this is even better: b = b'A\r\n' > It seems like bytes.decode always replaces "\n" with "\r\n". What makes you say that? You are passing the output through print, which does things with newlines and carriage returns. Try this, for example: py> print('ABCD\rZ\n', end='') ZBCD The best way to see what your string actually contains is the print the repr: print(repr(b.decode('utf-8'))) which I'm pretty sure will print A\r\n as you expect. But I don't have a Windows box to test it on. ---------- nosy: +steven.daprano _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40863> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com