Issue #837 resolved

Make CP_fileobject specific to the Python version running the WSGI server

Anonymous created an issue

CherryPy wsgi server subclasses socket._fileobject which has changed its internal read buffer from Python 2.6 (with a possibility of backporting to Python 2.5).

Implement CP_fileobject to support the new buffering type (StringIO) and ensure we match the Python version when running the server.


Reported by lawouach

Comments (14)

  1. Anonymous

    To reproduce the problem, I checkout python trunk code, and install cherrypy againtst it.

    Python 2.6b1+ (trunk:64757, Jul 6 2008, 23:16:51)

    I noticed CP_fileobject subclass socket._fileobject , and some methods are mostly identical, so I simplay delete following instance method of CP_fileobject: flush, read, readline. The Good: simple things work. The Bad: I run testsuite, three fails. Please see attachment for further detail.

  2. Anonymous

    Well it seems it would make little sense for CP to inherit _fileobject if you were not redefining its methods. For instance that class doesn't call directly self._sock.* method but wraps them into its own methods to trap some errors.

  3. Anonymous

    Reference original code, I mainly import socket._fileobject from latest python trunk, add appropriate error handling code. python 2.3, 2.4,2.5 all pass the test suite. Python 2.6 still see some compatibility issue, all related with trunked response, I believe that belongs another ticket.

    Please review updated.diff.

  4. Anonymous

    Attached is a patch that would solved the issue against Python 2.6b2. I've also updated a few tests accordingly. I've checked and the full test suite passed on Python 2.5.2 and Python 2.6b2. I couldn't try with other versions (notably older ones).

  5. Anonymous

    Hi Sylvain,

    I think that in the test checking for version 2.6 you forgot to add an 'or' clause for version 2.5.2 because without this clause I still can't use cherrypy with python 2.5.2

  6. Christian Wyglendowski

    Lawouach - Thanks for doing the initial work on this. I took up the '''huge''' task (wink, wink) of adding in a clause for Python 2.5.2.

    Is there anything in here preventing us from committing this to trunk? I'm guessing that SSL is still an issue, but I don't have the proper libs installed to test it at this point. Should the lack of SSL support keep it out of trunk though?

  7. Christian Wyglendowski

    Ok, sporadic issues appear to be gone. Looked like the original 837.patch was making calls to some buffer callable that wasn't actually present in the wsgiserver. Odd that all the unittests still passed ...

  8. Log in to comment