Issue #1131 new

cherrypy.wsgiserver.wsgiserver2.ChunkedRFile.__iter__ broken

Anonymous created an issue

cherrypy.wsgiserver.wsgiserver2.ChunkedRFile.iter references sizehint, which is not defined:

My code: {{{


def disable_prb(): cherrypy.request.process_request_body = False = cherrypy.Tool('before_request_body', disable_prb)

class Root(object): @cherrypy.expose def index(self): for line in cherrypy.request.rfile: print "got line: " + line }}}

Error: {{{ [09/Mar/2012:14:44:15] HTTP Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/cherrypy/", line 656, in respond response.body = self.handler() File "/usr/lib/python2.7/dist-packages/cherrypy/lib/", line 188, in call self.body = self.oldhandler(*args, kwargs) File "/usr/lib/python2.7/dist-packages/cherrypy/", line 34, in __call__ return self.callable(*self.args, self.kwargs) File "", line 19, in index for line in cherrypy.request.rfile: File "/usr/lib/python2.7/dist-packages/cherrypy/wsgiserver/", line 513, in iter line = self.readline(sizehint) NameError: global name 'sizehint' is not defined }}} {{{


def __iter__(self):
    # Shamelessly stolen from StringIO
    total = 0
    line = self.readline(sizehint)
    while line:
        yield line
        total += len(line)
        if 0 < sizehint <= total:
        line = self.readline(sizehint)


Comments (3)

  1. Jim Paris

    (I was the original reporter)

    It's even worse. and ChunkedRFile.readline() are both broken and get stuck in a loop if size = None.

    I'll put together a testcase

  2. Log in to comment