Message235249
| Author |
martin.panter |
| Recipients |
anacrolix, benjamin.peterson, docs@python, martin.panter, neologix, petri.lehtinen, pitrou, python-dev, sbt, stutzbach |
| Date |
2015年02月02日.12:52:29 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1422881550.14.0.255323463545.issue13322@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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. |
|