New submission from Antoine Pitrou <pit...@free.fr>: 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) ---------- components: IO, Library (Lib) messages: 116408 nosy: amaury.forgeotdarc, benjamin.peterson, pitrou, stutzbach priority: normal severity: normal status: open title: SocketIO should return None on EWOULDBLOCK type: behavior versions: Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9854> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com