Patches item #1359365, was opened at 2005-11-18 01:03 Message generated for change (Comment added) made by loewis You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1359365&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: None >Status: Closed Resolution: Accepted Priority: 5 Private: No Submitted By: Walter Dörwald (doerwalter) Assigned to: Walter Dörwald (doerwalter) Summary: Iterating closed StringIO.StringIO Initial Comment: This patch changes StringIO.StringIO.next to raise a ValueError when the stream is closed. This is the same behaviour as for cStringIO.StringIO and real files. ---------------------------------------------------------------------- >Comment By: Martin v. Löwis (loewis) Date: 2006-11-19 11:45 Message: Logged In: YES user_id=21627 Originator: NO doerwalter: I think it should. StringIO was already behaving that way, so only cStringIO needed to distinguish between -1 and no argument (passing None isn't supported - it isn't for regular files, either). I committed this as r52788, and think that this issue can now be closed. I don't think this change should be backported, as it may break applications, for no good reason. ---------------------------------------------------------------------- Comment By: Walter Dörwald (doerwalter) Date: 2006-11-13 18:39 Message: Logged In: YES user_id=89016 Calling file.truncate() without a argument does a "truncate to current position" so maybe StringIO should raise IOError(EINVAL) on truncate(-1) and both should truncate to the current position on truncate(None)? ---------------------------------------------------------------------- Comment By: Georg Brandl (gbrandl) Date: 2006-11-13 17:46 Message: Logged In: YES user_id=849994 Well, standard C specifies to return EINVAL on negative length. I'm not sure if we should deviate from that behavior as long as files are a quite thin wrapper around standard C files. ---------------------------------------------------------------------- Comment By: Walter Dörwald (doerwalter) Date: 2006-11-13 16:50 Message: Logged In: YES user_id=89016 truncate() hasn't been changed yet: cStringIO.StringIO.truncate() treats a negative argument as "truncate to the current position". file.truncate() raises a "IOError: [Errno 22] Invalid argument". In this case the StringIO behaviour seems to be the preferable one. ---------------------------------------------------------------------- Comment By: Martin v. Löwis (loewis) Date: 2006-11-12 19:51 Message: Logged In: YES user_id=21627 What is the status of this patch? Is there any further action necessary? ---------------------------------------------------------------------- Comment By: Walter Dörwald (doerwalter) Date: 2006-03-15 23:14 Message: Logged In: YES user_id=89016 Checked in a fix for cStringIO.StringIO.isatty() as r43054. ---------------------------------------------------------------------- Comment By: Guido van Rossum (gvanrossum) Date: 2006-03-15 18:37 Message: Logged In: YES user_id=6380 Sure. ---------------------------------------------------------------------- Comment By: Walter Dörwald (doerwalter) Date: 2006-03-15 09:25 Message: Logged In: YES user_id=89016 Checked in as r43039. What do we do with the other discrepancies. Change cStringIO for both the isatty() and the truncate() problems? ---------------------------------------------------------------------- Comment By: Guido van Rossum (gvanrossum) Date: 2006-03-15 06:31 Message: Logged In: YES user_id=6380 Please check this in if you haven't already done so. I need to shed load! ---------------------------------------------------------------------- Comment By: Walter Dörwald (doerwalter) Date: 2005-11-29 17:36 Message: Logged In: YES user_id=89016 There are other discrepancies between StringIO.StringIO and cString.StringIO: isatty() raises a ValueError() for a closed StringIO.StringIO and a closed file, but not for a closed cStringIO.StringIO. And the truncate() method when called with a negative argument raised an IOError for StringIO.StringIO and real files, but not for cStringIO.StringIO. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1359365&group_id=5470 _______________________________________________ Patches mailing list Patches@python.org http://mail.python.org/mailman/listinfo/patches