cStringIO problem with new version of cherrypy

28 views
Skip to first unread message

Nicolas Évrard

unread,
Jul 4, 2008, 4:14:04 AM7/4/08
to cherryp...@googlegroups.com
Hello,

Today I did a svn up (I'm now at revision 2012) to test my application
with the new and shiny cherrypy.

But when I try to contact the server I've got the following tracebacks
in the browser:

File "/home/nicoe/python/cherrypy/wsgiserver/__init__.py", line 983, in communicate
req.parse_request()
File "/home/nicoe/python/cherrypy/wsgiserver/__init__.py", line 304, in parse_request
self._parse_request()
File "/home/nicoe/python/cherrypy/wsgiserver/__init__.py", line 317, in _parse_request
request_line = self.rfile.readline()
File "/home/nicoe/python/cherrypy/wsgiserver/__init__.py", line 212, in readline
data = self.rfile.readline(256)
File "/home/nicoe/python/cherrypy/wsgiserver/__init__.py", line 823, in readline
nl = data.find('\n', 0, size)
AttributeError: 'cStringIO.StringO' object has no attribute 'find'


Does anybody knows what can cause this bug ?

--
(°> Nicolas Évrard
/ ) Liège - Belgique
^^

Sylvain Hellegouarch

unread,
Jul 4, 2008, 5:39:49 AM7/4/08
to cherryp...@googlegroups.com

You're using a new version of Python and they changed the way to buffer
the read input in socket._fileobject. At least up to Python 2.5.x they
were using a string. They moved to a StringIO object.

http://svn.python.org/view/python/trunk/Lib/socket.py?rev=63788&view=markup

Look at the __init__() method of socket._fileobject.

The problem is that CherryPy inherits from socket._fileobject and
overwrites some of the methods like readline(). The subclass therefore
expects self._rbug to be a string, not a StringIO.

I don't know how Robert would like to handle that case (probably a huge if
on the Python version and have two distinct CP_fileobject classes.

For now your best bet is to downgrade your Python version to 2.5.2

- Sylvain

--
Sylvain Hellegouarch
http://www.defuze.org

Sylvain Hellegouarch

unread,
Jul 4, 2008, 5:47:13 AM7/4/08
to cherryp...@googlegroups.com

> You're using a new version of Python and they changed the way to buffer
> the read input in socket._fileobject. At least up to Python 2.5.x they
> were using a string. They moved to a StringIO object.
>
> http://svn.python.org/view/python/trunk/Lib/socket.py?rev=63788&view=markup
>
> Look at the __init__() method of socket._fileobject.

FYI the rational behind that change:
http://svn.python.org/view?rev=62627&view=rev

They might backport it to 2.5 too eventually.

Nicolas Évrard

unread,
Jul 4, 2008, 6:04:33 AM7/4/08
to cherryp...@googlegroups.com
* Sylvain Hellegouarch [2008-07-04 11:39 +0200]:

Thank you Sylvain for this quick anwser, I will use python2.4 for my
tests.

Jim Jones

unread,
Jul 6, 2008, 7:00:19 AM7/6/08
to cherryp...@googlegroups.com

does this affect the just released CP 3.1.0?

-jim


Robert Brewer

unread,
Jul 6, 2008, 10:49:14 AM7/6/08
to cherryp...@googlegroups.com

Yes, it does. Do we have a ticket yet?


Robert Brewer
fuma...@aminus.org

nus...@gmail.com

unread,
Jul 8, 2008, 1:35:08 PM7/8/08
to cherrypy-users
Hi, I find out CP_fileobject.{flush|read|readline} are mostly
identical to its superclass socket._fileobject.
I tried delete these 3 methods, and got a working cherrypy on Python
2.6b1+ (trunk:64757, Jul 6 2008, 23:16:51)
Later on, I rerun the testsuite
on python 2.5.1: all tests pass
on python 2.6: only 3 tests failed.
Unfortunately I couldn't tracking down python 2.6 related problems,
please see attached logs under ticket 837 for details.
> fuman...@aminus.org
Reply all
Reply to author
Forward
0 new messages