This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients amaury.forgeotdarc, benjamin.peterson, pitrou, stutzbach
Date 2010-09-14.16:19:54
SpamBayes Score 8.12572e-13
Marked as misclassified No
Message-id <1284481211.95.0.424459514211.issue9854@psf.upfronthosting.co.za>
In-reply-to
Content
SocketIO claims to implement RawIOBase, but it lets blocking IO errors pass through on non-blocking sockets:

>>> s = socket.create_connection(("python.org", 80)); s.settimeout(0.0)
>>> f = s.makefile("rb", buffering=0)
>>> f.readinto(bytearray(10))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/antoine/py3k/nntp-9360/Lib/socket.py", line 228, in readinto
    return self._sock.recv_into(b)
socket.error: [Errno 11] Resource temporarily unavailable

Instead, readinto() should detect the blocking condition (EAGAIN / EWOULDBLOCK) and return None (same for write(), I imagine).

There also seems to be a problem in the default read() implementation in RawIOBase, which doesn't accept a possible None result from readinto():

>>> f.readinto = lambda x: None
>>> f.read(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object cannot be interpreted as an integer

(the RawIOBase docs themselves don't mention that readinto() can return None, but it's the only logical possibility: catching EWOULDBLOCK in read() but not in readinto() wouldn't make sense)
History
Date User Action Args
2010-09-14 16:20:12pitrousetrecipients: + pitrou, amaury.forgeotdarc, benjamin.peterson, stutzbach
2010-09-14 16:20:11pitrousetmessageid: <1284481211.95.0.424459514211.issue9854@psf.upfronthosting.co.za>
2010-09-14 16:19:55pitroulinkissue9854 messages
2010-09-14 16:19:54pitroucreate