471,579 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,579 software developers and data experts.

cStringIO change in 2.4 vs 2.5. Regression?

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
Jun 1 '07 #1
3 1497

"Markus Schöpflin" <no****@no.spamwrote in message
news:f3**********@nntp.ilk.net...
| Hello,
|
| I just stumbled accross a difference between cStringIO in Python 2.4
| and 2.5. You can no longer feed arrays to cStringIO.
[snip]
| Has this change been done on purpose or is it a regression?

I doubt that an intentional change would have been made for cStringIO and
not StringIO. Two ways to investigate: scan the detailed listing of 2.5
changes for mention of array and cStringIO modules; check the source code
checkin messages for both for the relevant time period. This might also
suggest who to send an inquiry to who might not be reading here.

If you do not get a satifactory resolution here, file a bug report on SF.
But remember that all bug fixers are volunteers just like you, so any
investigation you do and report on to make response easier will likely make
it quicker also.

tjr

Jun 1 '07 #2
Terry Reedy wrote:
"Markus Schöpflin" <no****@no.spamwrote in message
news:f3**********@nntp.ilk.net...
| Hello,
|
| I just stumbled accross a difference between cStringIO in Python 2.4
| and 2.5. You can no longer feed arrays to cStringIO.
[snip]
| Has this change been done on purpose or is it a regression?

I doubt that an intentional change would have been made for cStringIO and
not StringIO. Two ways to investigate: scan the detailed listing of 2.5
changes for mention of array and cStringIO modules; check the source code
checkin messages for both for the relevant time period. This might also
suggest who to send an inquiry to who might not be reading here.
First of all, thank you very much for you answer and sorry for the
late reply, I was AFK for some days.

I scanned the NEWS file and the only change which caught my attention is

- Patches #1298449 and #1298499: Add some missing checks for error
returns in cStringIO.c.

but the corresponding check-in doesn't look suspicious.

Next I had a look at the source code of the trunk:

cStringIO.c:newIobject() calls abstract.c:PyObject_AsCharBuffer(),
which, AFAICT, is the only possible source for the exception reported.
The exception is raised when the given object doesn't have
conversions to an I/O buffer, but when looking at arraymodule.c there
is array_as_buffer which provides the needed conversions.

The code looks pretty much the same on the 2.5 branch, so I don't have
an explanation for the observed behaviour.
If you do not get a satifactory resolution here, file a bug report on SF.
But remember that all bug fixers are volunteers just like you, so any
investigation you do and report on to make response easier will likely make
it quicker also.
I think I'll file a bug at SF... maybe someone else will spot something.

Thanks, Markus
Jun 13 '07 #3
Markus Schöpflin wrote:

[...]
I think I'll file a bug at SF... maybe someone else will spot something.
Should have checked the bugtracker first... it was reported the day
after my original post:
http://sourceforge.net/tracker/index...70&atid=105470

And it's a 2.5.1 regression, it does work in 2.5.

Markus
Jun 13 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Michael van der Veeke | last post: by
3 posts views Thread by Laszlo Nagy | last post: by
1 post views Thread by garyjefferson123 | last post: by
3 posts views Thread by Paul Rubin | last post: by
5 posts views Thread by peppergrower | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
1 post views Thread by lumer26 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.