[Patches] [ python-Patches-1374063 ] Broader iterable support for xmlrpclib

SourceForge.net noreply at sourceforge.net
Sun Dec 3 13:32:55 CET 2006

Patches item #1374063, was opened at 2005-12-06 05:14
Message generated for change (Comment added) made by loewis
You can respond by visiting: 

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
Status: Open
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: Skip Montanaro (montanaro)
>Assigned to: Skip Montanaro (montanaro)
Summary: Broader iterable support for xmlrpclib

Initial Comment:
The XML-RPC spec supports a fairly limited set of datatypes.
Most languages, Python included, contain many more types
than XML-RPC.  Some types, such as Python's complex number
type, have no reasonable analog in XML-RPC.  Others, such as
unicode objects and array objects do.  This patch allows
anything that can be converted to a list but that is not
otherwise supported directly by the xmlrpclib module already
to be marshalled as an XML-RPC array if the allow_iter
parameter to the ServerProxy constructor evaluated to true.
This includes sets and arrays.


1. Python already overloads the XML-RPC array type with both
   lists and tuples.  This just extends that overloading to
   other currently unsupported Python types which can be
   converted to lists.  Why should lists and tuples have all the

2. Providing transparent conversion to XML-RPC arrays keeps
   calling code a bit cleaner.  One of the attractions of
   XML-RPC is that the remote procedure call looks identical
   to a local call.  This is especially true in Python
   because of /F's excellent little _Method class.  Clearly
   as a programmer I could type:

       import array
       a = array.array('i', [1, 2,3])
       from somemodule import somefunction
       print somefunction(list(a))

   but that reveals details of the implementation of
   somefunction, namely that it can't handle arrays
   directly, even though in most respects arrays
   and lists are interchangeable.

Attached is a patch for the xmlrpclib library that
implements this feature, including minor doc changes and a
new test case.


>Comment By: Martin v. Löwis (loewis)
Date: 2006-12-03 13:32

Logged In: YES 
Originator: NO

The patch is fine. Notice that it is currently out of date, due to
inclusion of patch #1070046.

This other patch added generic support for objects having an __dict__
attribute, marshaling them struct elements. This is in real conflict to
this patch: an object both supporting a list conversion and having a
__dict__ attribute could be marshaled either way.

My proposal is to resolve this in favor of this patch: If an object has a
list conversion, it's most likely meant to be a list.

If you agree to this resolution, please update the code and the
documentation, and apply this patch.


Comment By: Skip Montanaro (montanaro)
Date: 2005-12-06 05:23

Logged In: YES 

Oh, I forgot my original use case.  I was constructing a list of
from a larger data structure and used a set to guarantee uniqueness
during construction.  I didn't really care about element ordering.  I
either had to convert the set to a list when calling the local function
that made the RPC call, or modify the local function to always convert
that arg to a list.  Both alternatives seemed unattractive to me.


You can respond by visiting: 

More information about the Patches mailing list