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

Guido van Rossum guido at python.org
Thu Aug 23 01:42:39 CEST 2007


Thanks! I've checked the bulk of this in, excepting the fix for #3,
which I fixed at the source in longobject.c. Also, I changed the call
to io.StringIO() to first convert the bytes to characters, using the
same encoding as used for the HTTP request header line (Latin-1).

--Guido

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.
>
>
> 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/guido%40python.org
>
>
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list