eryksun added the comment:
It works if you detach the buffer beforehand:
>>> import io, sys
>>> stdin = sys.stdin
>>> stdin.flush()
>>> correct_stdin = io.TextIOWrapper(stdin.buffer, 'utf-8')
>>> correct_stdin.readline()
foobar
'foobar\n'
>>> correct_stdin.detach()
<_io.BufferedReader name='<stdin>'>
>>> del correct_stdin
>>> stdin.readline()
foobar
'foobar\n'
----------
nosy: +eryksun
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue21363>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com