[New-bugs-announce] [issue12244] cStringIO inconsistencies

Santoso Wijaya report at bugs.python.org
Thu Jun 2 20:50:57 CEST 2011

New submission from Santoso Wijaya <santoso.wijaya at gmail.com>:


Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on
Type "help", "copyright", "credits" or "license" for more information.
>>> from cStringIO import StringIO
>>> result = StringIO('Hello, ')
>>> result.write('world')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'cStringIO.StringI' object has no attribute 'write'
>>> result = StringIO()
>>> result.write('Hello, world')
>>> print result.getvalue()
Hello, world
>>> from StringIO import StringIO
>>> result = StringIO('Hello, ')
>>> result.write('world')
>>> print result.getvalue()

Few things:
1. The error message says, "StringI" instead of "StringIO".
2. Why does a cStringIO.StringIO object instantiated with a starter string not have the `write` attribute?
3. Using the pure-Python equivalent, (2) succeeds but it overwrites the starter string?
4. Regardless, (2) and (3) are not consistent with each other.

components: Library (Lib)
messages: 137490
nosy: santa4nt
priority: normal
severity: normal
status: open
title: cStringIO inconsistencies
type: behavior
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list