Index: Doc/lib/libxmlrpclib.tex =================================================================== --- Doc/lib/libxmlrpclib.tex (revision 54264) +++ Doc/lib/libxmlrpclib.tex (working copy) @@ -35,11 +35,10 @@ \url{http://ontosys.com/xml-rpc/extensions.php} for a description. The \var{use_datetime} flag can be used to cause date/time values to be presented as \class{\refmodule{datetime}.datetime} objects; this is false -by default. \class{\refmodule{datetime}.datetime}, +by default. Only \class{\refmodule{datetime}.datetime} +objects may be passed to calls. The programmer must explicitly convert \class{\refmodule{datetime}.date} and \class{\refmodule{datetime}.time} -objects may be passed to calls. \class{\refmodule{datetime}.date} objects -are converted with a time of ``00:00:00''. -\class{\refmodule{datetime}.time} objects are converted using today's date. +objects to \class{\refmodule{datetime}.datetime} objects first. Both the HTTP and HTTPS transports support the URL syntax extension for HTTP Basic Authentication: \code{http://user:pass@host:port/path}. The @@ -65,8 +64,9 @@ \lineii{integers}{Pass in directly} \lineii{floating-point numbers}{Pass in directly} \lineii{strings}{Pass in directly} - \lineii{arrays}{Any Python sequence type containing conformable - elements. Arrays are returned as lists} + \lineii{arrays}{Any Python sequence type which can be converted to a + list and which contains conformable + elements. Arrays are returned as lists.} \lineii{structures}{A Python dictionary. Keys must be strings, values may be any conformable type. Objects of user-defined classes can be passed in; @@ -323,7 +323,11 @@ \var{encoding}, if supplied, is the encoding to use in the generated XML; the default is UTF-8. Python's \constant{None} value cannot be used in standard XML-RPC; to allow using it via an extension, -provide a true value for \var{allow_none}. +provide a true value for \var{allow_none}. Iterables other than +strings, lists, tuples and dictionaries will be marshalled transparently as +structures if they support a __dict__ method which returns a dictionary +of conformable types or to lists if they can be converted to a list with +the \var{list} builtin. \end{funcdesc} \begin{funcdesc}{loads}{data\optional{, use_datetime}} Index: Lib/xmlrpclib.py =================================================================== --- Lib/xmlrpclib.py (revision 54264) +++ Lib/xmlrpclib.py (working copy) @@ -634,13 +634,21 @@ try: value.__dict__ except: - raise TypeError, "cannot marshal %s objects" % type(value) - # check if this class is a sub-class of a basic type, - # because we don't know how to marshal these types - # (e.g. a string sub-class) - for type_ in type(value).__mro__: - if type_ in self.dispatch.keys(): - raise TypeError, "cannot marshal %s objects" % type(value) + try: + lst = list(value) + except TypeError: + raise TypeError, ("cannot marshal %s objects" % + type(value)) + else: + self.dump_array(lst, write) + return + # check if this class is a sub-class of a basic type, + # because we don't know how to marshal these types + # (e.g. a string sub-class) + for type_ in type(value).__mro__: + if type_ in self.dispatch.keys(): + raise TypeError, ("cannot marshal %s objects" % + type(value)) f = self.dispatch[InstanceType] f(self, value, write) Index: Lib/test/test_xmlrpc.py =================================================================== --- Lib/test/test_xmlrpc.py (revision 54264) +++ Lib/test/test_xmlrpc.py (working copy) @@ -114,6 +114,14 @@ xmlrpclib.loads(strg)[0][0]) self.assertRaises(TypeError, xmlrpclib.dumps, (arg1,)) + def test_dump_iter(self): + import array + value = array.array('i', [1,2,3]) + arg1 = (value,) + strg = xmlrpclib.dumps(arg1) + self.assertEquals(list(value), + xmlrpclib.loads(strg)[0][0]) + def test_default_encoding_issues(self): # SF bug #1115989: wrong decoding in '_stringify' utf8 = """