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: cStringIO class name typo
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: alexandre.vassalotti, qwjqwj, vdupras
Priority: normal Keywords:

Created on 2009-02-22 07:09 by qwjqwj, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg82595 - (view) Author: (qwjqwj) Date: 2009-02-22 07:09
It has a typo error in cStringIO.StringIO's class name "StringO":

>>> import cStringIO
>>> a=cStringIO.StringIO()
>>> a
<cStringIO.StringO object at 0xb7eef240>
>>> a.__class__.__name__
'StringO'

So we can't unpickle the object correctly with Python 2.5.4:

>>> import pickle
>>> pickle.loads(pickle.dumps(a))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.5/pickle.py", line 1366, in dumps
    Pickler(file, protocol).dump(obj)
  File "/usr/local/lib/python2.5/pickle.py", line 224, in dump
    self.save(obj)
  File "/usr/local/lib/python2.5/pickle.py", line 306, in save
    rv = reduce(self.proto)
  File "/usr/local/lib/python2.5/copy_reg.py", line 69, in _reduce_ex
    raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle StringO objects


When using multiprocess library, it also use the pickling and unpickling
of cStringIO.StringIO object
msg82596 - (view) Author: (qwjqwj) Date: 2009-02-22 07:13
This bug also exists in Python 2.6.1
msg82600 - (view) Author: Virgil Dupras (vdupras) (Python triager) Date: 2009-02-22 12:35
The documentation says:

"Another difference from the StringIO module is that calling StringIO() 
with a string parameter creates a read-only object. Unlike an object 
created without a string parameter, it does not have write methods. These 
objects are not generally visible. They turn up in tracebacks as StringI 
and StringO."

And there seem to have been some activity about this around r33834.
msg85297 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-04-03 06:03
This is not a typo. cStringIO.StringIO is a factory function that
returns either a cStringO object (for writing) or cStringI (for
reading). If this behavior causes a problem to you, then consider using
StringIO.StringIO.

Alternatively, you could upgrade to Python 2.7 or 3.0 and use
io.StringIO() which doesn't have this limitation.
History
Date User Action Args
2022-04-11 14:56:46adminsetgithub: 49595
2009-04-03 21:20:33benjamin.petersonsetstatus: open -> closed
2009-04-03 06:03:29alexandre.vassalottisetresolution: wont fix

messages: + msg85297
nosy: + alexandre.vassalotti
2009-02-22 12:35:21vduprassetnosy: + vdupras
messages: + msg82600
2009-02-22 07:13:34qwjqwjsetmessages: + msg82596
2009-02-22 07:09:35qwjqwjcreate