Issue #4 resolved

New code in method copy_body (changeset 9b766e181f13 of WebOb) brokes test

Mariano Mara
repo owner created an issue

Sergey, please let me know if I'm wrong but, in your new version of copy_body (from the official repo of WebOb) the read() action after the 'else' seems to be missing the mandatory length parameter. In this repo (tests/test_request.py) I have a test ("test_body_property") that fails after merging the last changes from WebOb with the following traceback:

{{{

!python

Traceback (most recent call last): File "/home/mariano/Sandbox/WEBOB/python/compiled/python2.7/lib/python2.7/site-packages/nose-1.0.0-py2.7.egg/nose/case.py", line 187, in runTest self.test(self.arg) File "/home/mariano/Sandbox/WEBOB/webobtestcoverage/tests/test_request.py", line 502, in test_body_property eq_(len(r.body), len(string.letterslen_strl)-1) File "/home/mariano/Sandbox/WEBOB/webobtestcoverage/webob/request.py", line 428, in _body__get self.make_body_seekable() File "/home/mariano/Sandbox/WEBOB/webobtestcoverage/webob/request.py", line 657, in make_body_seekable self.copy_body() File "/home/mariano/Sandbox/WEBOB/webobtestcoverage/webob/request.py", line 673, in copy_body self.body = self.body_file.read() TypeError: read() takes exactly 2 arguments (1 given)

}}}

I appreciate your comments.

Mariano

Comments (3)

  1. Sergey Schetinin
    • changed status to open

    PEP 333 specifies method as `read(size)` but mentions that "The semantics of each method are as documented in the Python Library Reference [..]" which would suggest that the argument is optional.

    If you can find a more definite reference to the argument not being optional, that would be great.

    Maybe I should change it to read(-1) just to be on the safe side.

  2. Mariano Mara reporter

    Last night I could have sworn that 'size' was a mandatory parameter, seems I need to trust less in my memory and check the library more. Looks like the problem was in my test where I defined a Dummy StringIO object (with no 'seek' method just to test 'make_body_seekable') but I defined read with the mandatory size parameter, hence the error. Sorry for wasting your time.

    Anyway if you consider a read(-1) as safer could be worth implementing it.

  3. Log in to comment