Message235249
Looking at test_io.BufferedReaderTest.test_read_non_blocking(), at Lib/test/test_io.py:1037, there are explicit tests for ‘peek(1) == b"" ’ and ‘read() is None’. The peek() test was added in revision 3049ac17e256, in 2009 (large merge of “io” implementation in C; can’t find more detailed history). The read() test was added in revision 21233c2e5d09 in 2007, with a remark about a “tentative decision to drop nonblocking I/O support from the buffering layers”.
My suggestion is to make the read/into/1/all/peek() methods all return None if no non-blocking data is available, and return a short non-empty result if some data was available but not enough to satisfy the equivalent blocking call. However, this would invove changing the behaviour of BufferedReader.read1() and peek(); would that be allowed?
The readline() based methods could probably work similarly, but that would be another issue and a bigger change, because the equivalent RawIOBase methods do not return None. |
|
Date |
User |
Action |
Args |
2015-02-02 12:52:30 | martin.panter | set | recipients:
+ martin.panter, pitrou, benjamin.peterson, stutzbach, anacrolix, neologix, docs@python, python-dev, sbt, petri.lehtinen |
2015-02-02 12:52:30 | martin.panter | set | messageid: <1422881550.14.0.255323463545.issue13322@psf.upfronthosting.co.za> |
2015-02-02 12:52:30 | martin.panter | link | issue13322 messages |
2015-02-02 12:52:29 | martin.panter | create | |
|