Message273258
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. |
|
Date |
User |
Action |
Args |
2016-08-21 01:42:31 | martin.panter | set | recipients:
+ martin.panter, pitrou, benjamin.peterson, stutzbach, r.david.murray, python-dev, hynek, serhiy.storchaka, Dolda2000 |
2016-08-21 01:42:31 | martin.panter | set | messageid: <1471743751.63.0.927160763341.issue20074@psf.upfronthosting.co.za> |
2016-08-21 01:42:31 | martin.panter | link | issue20074 messages |
2016-08-21 01:42:30 | martin.panter | create | |
|