xmlrpclib - error marshalling new-style classes

Gabriel PASTOR pastor.gabriel at wanadoo.fr
Tue Nov 16 13:33:43 CET 2004

I'm trying to send object using xmlrpclib, but it seems that classes inheriting from object cannot be marshalled. Here is an example:

-------- server.py --------
import xmlrpclib, SimpleXMLRPCServer

class MyObject(object):
    def __init__(self,name):        
def getMyObject(name):
    obj = MyObject(name)
    return obj

if __name__ == "__main__":
    server =  SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8888))
    print 'server running on port 8888' 

---- client.py ------
import xmlrpclib, SimpleXMLRPCServer
server = xmlrpclib.ServerProxy("http://localhost:8888")
obj = server.getMyObject('john')
print obj

I get the following error
xmlrpclib.Fault: <Fault 1: "exceptions.TypeError:cannot marshal <class '__main__
.MyObject'> objects">

And if the class MyObject doesn't inherit from object then the program runs correctly. I have this problem using python 2.3 and the problem is exacltly the same with python 2.4 beta1

Am I doing something wrong or is it a bug in xmlrpclib ?



More information about the Python-list mailing list