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

John Reese john.reese at gmail.com
Thu Aug 23 00:43:35 CEST 2007


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'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xmlrpc.patch
Type: application/octet-stream
Size: 3372 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-3000/attachments/20070822/aa87a546/attachment.obj 


More information about the Python-3000 mailing list