[Patches] [ python-Patches-951915 ] fix bug in StringIO.truncate -
length not changed
SourceForge.net
noreply at sourceforge.net
Wed May 12 12:59:52 EDT 2004
Patches item #951915, was opened at 2004-05-11 14:07
Message generated for change (Comment added) made by arigo
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=951915&group_id=5470
Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
Priority: 6
Submitted By: David Fraser (davidfraser)
Assigned to: Nobody/Anonymous (nobody)
Summary: fix bug in StringIO.truncate - length not changed
Initial Comment:
If truncate() is called on a StringIO object, the
length is not changed, so that seek(0, 2) calls will go
beyond the correct end of the file.
This patch adds a line to update the length, and a test
to the test method that checks that it works.
----------------------------------------------------------------------
>Comment By: Armin Rigo (arigo)
Date: 2004-05-12 16:59
Message:
Logged In: YES
user_id=4771
David, it seems to me that f.truncate(huge_value) would incorrectly set f.len to huge_value with your patch. Here is another patch fixing this and the other details I mentioned. I also put the new test into test_StringIO.py instead. Perhaps we should remove the if __name__=='__main__' bit, although it is nice as a quick example.
This makes me wonder if there is any reason left for which cStringIOs aren't subclassable, or if we care.
Alternatively, it makes me wonder if there wouldn't be a more efficient implementation of StringIO.py that would entierely avoid concatenating large strings, or if we care. This might make StringIO at least as efficient as cStringIO for some cases, e.g. when writing a lot of strings a few kb each, by avoiding the copy overhead.
----------------------------------------------------------------------
Comment By: Armin Rigo (arigo)
Date: 2004-05-12 15:34
Message:
Logged In: YES
user_id=4771
StringIO.py needs to be reviewed. I could spot several other (though more minor) problems in a couple of minutes.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=951915&group_id=5470
More information about the Patches
mailing list