Martin Panter added the comment:

Currently, the documentation for TextIOWrapper says it is “a buffered text 
stream over a BufferedIOBase binary stream.” If passing a RawIOBase 
(buffering=0) file works, that seems like an undocumented accident. This is 
also explicitly disallowed with open(). “Pass 0 to switch buffering off (only 
allowed in binary mode)”:

>>> open("/dev/tty", "r+t", buffering=0)
ValueError: can't have unbuffered text I/O

One benefit of requiring "r+b" mode to be seekable is that if you open a pipe 
for random access, it reports the error immediately, rather than after you have 
half written your data and then try to seek(). But I admit this difference 
between buffered=0 mode and random-access mode is obscure.

Given that seeking text streams is rather obscure (Issue 25849), and there are 
sometimes problems in conjunction with writing (Issue 12215) and with 
truncating (Issue 26158), it could make some sense to use BufferedRWPair in 
text mode. But IMO open() is already too complicated, so I am not excited about 
such a change.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20074>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to