Another issue in xmlrpclib

Roger Binns rogerb at rogerbinns.com
Sat Apr 3 18:25:35 EST 2004


This was a fun problem to track down.  The xmlrpclib._Method
object should do something about __str__/__repr__.

I have some code that prints out variables when an exception
happens, and if anything references one of those _Method
objects, then str/repr is called, which it tries to remote.
The real problem arises when the original exception occurred
doining some XML-RPC, so an exception is printed which when
it hits the _Method object causes another XML-RPC connection
to be made, which has an exception which when printed hits
the _Method object causes another XML-RPC connection to be
made, which has an exception which when printed ... (you get
the idea :-)

I don't know what the exact right solution for this is.
Amongst the possible solutions:

  - Inherit from object, which causes many Python special
    methods (stuff begining with __) to be defined (I am
    using this as it is the easiest)

  - In getattr, refuse to work if the method name starts
    with one or two underlines

  - In ServerProxy.__request filter the methodname

  - Do nothing

This issue could hit in other ways.  For example, if
someone makes a list of XML-RPC methods (via ServerProxy)
and then sorts them, various __cmp__ like functions
would be called and sent to the remote end.

Roger





More information about the Python-list mailing list