The readline method for StringIO defalt argument for the size arguement is None while for all other file-like objects it is -1. So if we pass in -1 to the StringIO readline method, all lines are returned, again inconsistent with the other file-like objects, and if we pass in None to any other file-like object we get a TypeError, int required. The attached python script is a very simple example of what I mean. Note that this is causing me a lot of grief in trying to get tests to pass for a simple fix to an open source project.
Logged In: YES user_id=1468643 BTW, another inconsistency between StringIO and cStringIO :-) >>> import cStringIO as c >>> sio = c.StringIO() >>> sio.write("aaaaa") >>> sio.truncate(0) >>> print sio.getvalue() >>> sio.write("bbbbb") >>> print sio.getvalue() aaaaabbbbb which I get in StringIO module is "bbbbb".
Logged In: YES user_id=1468643 Sorry, it seems the bug has been fixed in 2.4. >>>>>>>>>>>>>>>>>>> >>> import cStringIO as c >>> sio = c.StringIO() >>> sio.write("aaaaa") >>> sio.truncate(0) >>> print sio.getvalue() >>> sio.write("bbbbb") >>> print sio.getvalue() aaaaabbbbb which I get in StringIO module is "bbbbb".