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.

classification
Title: Inconsistency between StringIO and cStringIO
Type: Stage:
Components: None Versions: Python 2.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: cphsu, georg.brandl, mkerrin, rhettinger
Priority: normal Keywords:

Created on 2006-01-27 14:51 by mkerrin, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
stringiobug.py mkerrin, 2006-01-27 14:51
Messages (4)
msg27365 - (view) Author: Michael Kerrin (mkerrin) Date: 2006-01-27 14:51
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.
msg27366 - (view) Author: Kent Hsu (cphsu) Date: 2006-03-06 05:04
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".
msg27367 - (view) Author: Kent Hsu (cphsu) Date: 2006-03-06 05:16
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".
msg27368 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-03-18 08:24
Logged In: YES 
user_id=849994

Closing then.
History
Date User Action Args
2022-04-11 14:56:15adminsetgithub: 42842
2006-01-27 14:51:14mkerrincreate