[Python-3000] proposed fix for test_xmlrpc.py in py3k

Jeremy Hylton jeremy at alum.mit.edu
Thu Aug 23 16:37:35 CEST 2007


On 8/22/07, John Reese <john.reese at gmail.com> wrote:
> Good afternoon.  I'm in the Google Python Sprint working on getting
> the test_xmlrpc unittest to pass.  The following patch was prepared by
> Jacques Frechet and me.  We'd appreciate feedback on the attached
> patch.
>
> What was broken:
>
>
> 1. BaseHTTPServer attempts to parse the http headers with an
> rfc822.Message class.  This was changed in r56905 by Jeremy Hylton to
> use the new io library instead of stringio as before.  Unfortunately
> Jeremy's change resulted in TextIOWrapper stealing part of the HTTP
> request body, due to its buffering quantum.  This was not seen in
> normal tests because GET requests have no body, but xmlrpc uses POSTs.
>  We fixed this by doing the equivalent of what was done before, but
> using io.StringIO instead of the old cStringIO class: we pull out just
> the header using a sequence of readlines.

Thanks for the fix.  Are there any tests you can add to
test_xmlrpc_net that would have caught this error?  There was some
non-unittest test code in xmlrpc but it seemed to use servers or
requests that don't work anymore.  I couldn't find any xmlrpc servers
that I could use to test more than the getCurrentTime() test that we
currently have.

Jeremy

>
>
> 2. Once this was fixed, a second error asserted:
> test_xmlrpc.test_with{_no,}_info call .get on the headers object from
> xmlrpclib.ProtocolError.  This fails because the headers object became
> a list in r57194.  The story behind this is somewhat complicated:
>   - xmlrpclib used to use httplib.HTTP, which is old and deprecated
>   - r57024 Jeremy Hylton switched py3k to use more modern httplib
> infrastructure, but broke xmlrpclib.Transport.request; the "headers"
> variable was now referenced without being set
>   - r57194 Hyeshik Chang fixed xmlrpclib.Transport.request to get the
> headers in a way that didn't explode; unfortunately, it now returned a
> list instead of a dict, but there were no tests to catch this
>   - r57221 Guido integrated xmlrpc changes from the trunk, including
> r57158, which added tests that relied on headers being a dict.
> Unfortunately, it no longer was.
>
>
> 3. test_xmlrpc.test_fail_with_info was failing because the ValueError
> string of int('nonintegralstring') in py3k currently has an "s".  This
> is presumably going away soon; the test now uses a regular expression
> with an optional leading "s", which is a little silly, but r56209 is
> prior art.
>
> >>> int('z')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> ValueError: invalid literal for int() with base 10: s'z'
>
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/jeremy%40alum.mit.edu
>
>
>


More information about the Python-3000 mailing list