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 giampaolo.rodola
Recipients amaury.forgeotdarc, benjamin.peterson, giampaolo.rodola, pitrou, stutzbach
Date 2010-09-14.23:19:16
SpamBayes Score 3.5847657e-07
Marked as misclassified No
Message-id <1284506359.34.0.715812188339.issue9854@psf.upfronthosting.co.za>
In-reply-to
Content
I've never used socket.socket.makefile so I'm not sure, but its documentation says:

> The socket must be in blocking mode (it can not have a timeout).

If the statement is there because EAGAIN/EWOULDBLOCK were originally raised then it should be removed, otherwise I question whether makefile() is actually supposed to support non-blocking sockets in the first place.
IMO, I think it's a matter of figuring out whether makefile() should provide a socket-like behavior or a file like-behavior first.
In the first case I would expect all errors be raised as if I'm dealing with a common socket, otherwise they should be silenced/handled internally or makefile() just fail immediately as there's not such thing as "non-blocking files".

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

io.RawIOBase.readinto doc says: 

> Read up to len(b) bytes into bytearray b and return the number of bytes read.

...so returning 0 instead of None looks more natural to me.
Same for write, also because:

>>> open('xxx', 'w').write('')
0

I've also noticed that socket.SocketIO.readinto has a while loop which continues in case of EINTR and that's something which should be removed in case makefile() actually intends to support non-blocking sockets.
History
Date User Action Args
2010-09-14 23:19:19giampaolo.rodolasetrecipients: + giampaolo.rodola, amaury.forgeotdarc, pitrou, benjamin.peterson, stutzbach
2010-09-14 23:19:19giampaolo.rodolasetmessageid: <1284506359.34.0.715812188339.issue9854@psf.upfronthosting.co.za>
2010-09-14 23:19:17giampaolo.rodolalinkissue9854 messages
2010-09-14 23:19:16giampaolo.rodolacreate