473,545 Members | 2,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Strin gIO instance at 0x008DD080>
>>from cStringIO import StringIO
StringIO(a)
<cStringIO.Stri ngI 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.Strin gIO 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 1557

"Markus Schöpflin" <no****@no.spam wrote 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.spam wrote 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:new Iobject() calls abstract.c:PyOb ject_AsCharBuff er(),
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4905
by: Michael van der Veeke | last post by:
Hi All, Does anyone use any regression testing tools with MS Access? We have tried a few and none seem to work very well with a MS Access Front end and I need one. Can anyone provide any suggestions? Thanks Michael
3
6412
by: Laszlo Nagy | last post by:
This program: import sys import traceback import cStringIO a = 1.0 b = 0.0 try: c=a/b
1
1759
by: garyjefferson123 | last post by:
I want to accept a cStringIO object in a function in a python extension module. How do I do this? e.g., static PyObject *myfunc(PyObject *self, PyObject *args) { PyObject *cstringio; if (!PyArg_ParseTuple(args, "O:cStringIO", &cstringio)) { PyErr_SetString(PyExc_ValueError, "value must be a
3
3206
by: Paul Rubin | last post by:
Python 2.5 (r25:51908, Oct 6 2006, 15:24:43) on linux2 Type "help", "copyright", "credits" or "license" for more information. 'a' 'a' u'a' 'a\x00\x00\x00' I would have thought StringIO and cStringIO would return the same result for this ascii-encodeable string. Worse:
12
1641
by: Stefan Scholl | last post by:
After an hour searching for a potential bug in XML parsing (PyXML), after updating from 2.4 to 2.5, I found this one: $ python2.5 Python 2.5 (release25-maint, Dec 9 2006, 14:35:53) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "<stdin>", line 1, in <module>
1
2742
by: grbgooglefan | last post by:
I am importing cStringIO module in my PythonC++ embedded program. The import is failing with the following error: ImportError: /usr/lib/python2.3/lib-dynload/cStringIO.so: undefined symbol: PyObject_SelfIter I have python-2.3.3-88.9.x86 installed on my machine. Why is this error coming? how can I resolve this undefined symbol? Do I need...
1
2754
by: Borse, Ganesh | last post by:
Hi, Can you please guide me for the following problem? The call to "PyImport_ImportModule("cStringIO");" is failing with an error of "undefined symbol: PyObject_SelfIter". Before importing this module, I am importing only the sys module. Py_SetProgramName("/usr/bin/python"); Py_Initialize(); char* argv = { "python","-v",""};...
1
1720
by: grbgooglefan | last post by:
I am in a perculiar situation. I want to use PyRun_SimpleString for creating Python functions in embedded Python in C++. But there could be cases when Python function code compilation could fail & PyRun_SimpleString will return -1 as return status. At this time, it prints the error message to sys.stderr. So, we do not have any control or...
5
2790
by: peppergrower | last post by:
I've been experimenting with the 'with' statement (in __future__), and so far I like it. However, I can't get it to work with a cStringIO object. Here's a minimum working example: ### from __future__ import with_statement import cStringIO teststring='this is a test'
0
7425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7935
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7780
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.