Message116408
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) |
|
Date |
User |
Action |
Args |
2010-09-14 16:20:12 | pitrou | set | recipients:
+ pitrou, amaury.forgeotdarc, benjamin.peterson, stutzbach |
2010-09-14 16:20:11 | pitrou | set | messageid: <1284481211.95.0.424459514211.issue9854@psf.upfronthosting.co.za> |
2010-09-14 16:19:55 | pitrou | link | issue9854 messages |
2010-09-14 16:19:54 | pitrou | create | |
|