[ python-Bugs-901198 ] strange behaviour of xmlrpclib.Server proxy

SourceForge.net noreply at sourceforge.net
Sun Dec 4 18:26:27 CET 2005


Bugs item #901198, was opened at 2004-02-20 11:47
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=901198&group_id=5470

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: Python Library
>Group: Python 2.5
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Andreas Eisele (eisele)
>Assigned to: A.M. Kuchling (akuchling)
Summary: strange behaviour of xmlrpclib.Server proxy

Initial Comment:
Not quite sure this is a bug, but the problem caused me 
considerable time to track down (Python 2.3.2 on Solaris).

assume proxy is a variable for a server proxy created with
xmlrpclib.Server(), but sometimes it is None (assume a
default argument to a function).

The comparisons

if proxy != None:

or

if proxy:

fail with (to me) rather incomprehensible error messages.

However, the test

if proxy is not None:

does what I expect.

Is this a feature or a bug?


Thanks a lot for looking into it.

Andreas Eisele

----------------------------------------------------------------------

>Comment By: A.M. Kuchling (akuchling)
Date: 2005-12-04 12:26

Message:
Logged In: YES 
user_id=11375

Note that comparisons to None are better written as 'if
proxy is not None'; they're faster that way.

There's a more general problem here: any Python special
methods are forwarded via XML-RPC, so if you write 'proxy +
5', it tries to call __coerce__ and fails; if you write
'proxy[5]', it calls __getitem__ and fails.

One fix would be to implement all of these methods on
ServerProxy.  Another would be to ignore methods beginning
and ending with '__' in the __getattr__, but then you
couldn't call such methods at all.  

I suggest that there's really nothing to do here; if you try
certain operations on a ServerProxy, they'll fail.  Closing
as "won't fix".




----------------------------------------------------------------------

Comment By: Gerhard Reitmayr (merl7n)
Date: 2004-11-11 16:21

Message:
Logged In: YES 
user_id=12764

I also encountered the same bug. It appears that the
ServerProxy class does not implement the necessary operator
methods and therefore the defined __getattr__ method takes
over and gets it wrong. 

Adding the following methods to ServerProxy resolves the issue:

    def __eq__(self, other):
        return self is other
        
    def __ne__(self, other):
        return self is not other
        
    def __nonzero__(self):
        return True

It would be great, if this could be fixed in xmlrpclib.

Thanks,
  Gerhard Reitmayr

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=901198&group_id=5470


More information about the Python-bugs-list mailing list