[issue12244] cStringIO inconsistencies

2011-06-02 Thread Santoso Wijaya

New submission from Santoso Wijaya santoso.wij...@gmail.com:

Observe:

Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on
win32
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()
world,



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 rep...@bugs.python.org
http://bugs.python.org/issue12244
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12244] cStringIO inconsistencies

2011-06-02 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

1. The class for read-only objects is called StringI (the one for read-write 
objects is StringO).

2./3. This is documented: 
http://docs.python.org/library/stringio#cStringIO.StringIO

These differences between StringIO and cStringIO are unfortunate, but cannot be 
changed anymore in Python 2.  It's all different in Python 3 anyway, with 
io.StringIO being the successor to both.

--
nosy: +georg.brandl
resolution:  - wont fix
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12244
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12244] cStringIO inconsistencies

2011-06-02 Thread Santoso Wijaya

Santoso Wijaya santoso.wij...@gmail.com added the comment:

_ Should've read the docs again more carefully before submitting.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12244
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com