cStringIO change in 2.4 vs 2.5. Regression?
Markus Schöpflin
nospam at no.spam
Fri Jun 1 07:34:13 EDT 2007
Hello,
I just stumbled accross a difference between cStringIO in Python 2.4
and 2.5. You can no longer feed arrays to cStringIO.
Python 2.4:
---%<---
ActivePython 2.4.3 Build 12 (ActiveState Software Inc.) based on
Python 2.4.3 (#69, Apr 11 2006, 15:32:42) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from array import array
>>> a = array('B', (0, 1, 2))
>>> a
array('B', [0, 1, 2])
>>> from StringIO import StringIO
>>> StringIO(a)
<StringIO.StringIO instance at 0x008DD080>
>>> from cStringIO import StringIO
>>> StringIO(a)
<cStringIO.StringI object at 0x0086A248>
--->%---
Python 2.5:
---%<---
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from array import array
>>> a = array('B', (0, 1, 2))
>>> a
array('B', [0, 1, 2])
>>> from StringIO import StringIO
>>> StringIO(a)
<StringIO.StringIO instance at 0x008ED440>
>>> from cStringIO import StringIO
>>> StringIO(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected a character buffer object
--->%---
Has this change been done on purpose or is it a regression?
If it's not a regression, is there another way to feed an array to
cStringIO without expensive conversion?
TIA, Markus
More information about the Python-list
mailing list