homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: strange behaviour of xmlrpclib.Server proxy
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, eisele, merl7n
Priority: normal Keywords:

Created on 2004年02月20日 16:47 by eisele, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Messages (3)
msg20077 - (view) Author: Andreas Eisele (eisele) Date: 2004年02月20日 16:47
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
msg20078 - (view) Author: Gerhard Reitmayr (merl7n) Date: 2004年11月11日 21:21
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
msg20079 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2005年12月04日 17:26
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".
History
Date User Action Args
2022年04月11日 14:56:02adminsetgithub: 39961
2004年02月20日 16:47:36eiselecreate

AltStyle によって変換されたページ (->オリジナル) /