cStringIO problem with new version of cherrypy

View: New views
7 Messages — Rating Filter:   Alert me  

cStringIO problem with new version of cherrypy

by Nicolas Évrard-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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
^^

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: cStringIO problem with new version of cherrypy

by Sylvain Hellegouarch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



>
> 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 ?

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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: cStringIO problem with new version of cherrypy

by Sylvain Hellegouarch :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



> 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.


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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: cStringIO problem with new version of cherrypy

by Nicolas Évrard-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


* Sylvain Hellegouarch  [2008-07-04 11:39 +0200]:

>> 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 ?
>
>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.

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

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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: cStringIO problem with new version of cherrypy

by Jim Jones-8 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Fri, 2008-07-04 at 11:39 +0200, Sylvain Hellegouarch wrote:

> >
> > 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 ?
>
> 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

does this affect the just released CP 3.1.0?

-jim



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: cStringIO problem with new version of cherrypy

by Robert Brewer-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Jim Jones wrote:

> On Fri, 2008-07-04 at 11:39 +0200, Sylvain Hellegouarch wrote:
> > > 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 ?
> >
> > 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=ma

> rkup
> >
> > 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
>
> does this affect the just released CP 3.1.0?

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


Robert Brewer
fumanchu@...


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: cStringIO problem with new version of cherrypy

by nusgnaf@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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.

On Jul 6, 10:49 pm, "Robert Brewer" <fuman...@...> wrote:

> Jim Jones wrote:
> > On Fri, 2008-07-04 at 11:39 +0200, Sylvain Hellegouarch wrote:
> > > > 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 ?
>
> > > 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=ma
>
>
>
> > rkup
>
> > > 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
>
> > does this affect the just released CP 3.1.0?
>
> Yes, it does. Do we have a ticket yet?
>
> Robert Brewer
> fuman...@...

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---