Patches item #1771364, was opened at 2007-08-10 03:43 Message generated for change (Comment added) made by tiran You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1771364&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Library (Lib) Group: Python 3000 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Christian Heimes (tiran) Assigned to: Guido van Rossum (gvanrossum) Summary: Misc improvements for the io module Initial Comment: My patch fixes small parts of the io module: * replaced all asserts with appropriate TypeError() or ValueError() exceptions * default to buffering = 1 when raw is a tty * added four methods _checkSeekable(msg=None), _checkReadable, _checkWritable and _checkClosed as convenient methods to raise exceptions when a file is closed or not read, write or seekable. * added a unit test to check __all__ * SocketIO.readable/writeable checks for self.closed, too * SocketIO.readinto/write checks for readable, writeable and closed status __all__ references SocketIO but it is not available in io.py. The definition is in socket.py and it doesn't use any socket related code directly. What do you think about moving SocketIO to io.py in the sake of keeping everything together? NOTE: You may want to check my English in the exception messages. ;) ---------------------------------------------------------------------- >Comment By: Christian Heimes (tiran) Date: 2007-08-19 15:47 Message: Logged In: YES user_id=560817 Originator: YES I've added the message parameter for the case that we have to use a different error message. For example: self._checkReadable("Can't read from a closed socket") I've done a lot of Zope, twisted and Qt development lately. I prefer camel case but you are right. The Python core has to follow PEP 8. What do you think about _isreadable(), _iswritable(), _isseekable()? ---------------------------------------------------------------------- Comment By: Tony Lownds (tonylownds) Date: 2007-08-18 19:41 Message: Logged In: YES user_id=24100 Originator: NO Your English is fine :) The _checkSeekable etc methods are a good idea. But the message parameter is not used, so why have it? They should be lowercase names to match PEP 8. Also, shouldn't use the internal methods on parameters other than self: - assert raw.seekable() + raw._checkSeekable() I'm not sure it's a good idea to do the first todo without the second here: -XXX need to default buffer size to 1 if isatty() XXX need to support 1 meaning line-buffered ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1771364&group_id=5470 _______________________________________________ Patches mailing list Patches@python.org http://mail.python.org/mailman/listinfo/patches