Message220936
Hello. I noticed the following behaviour while working with xmlrpc proxy methods.
>>> import inspect, xmlrpc.client
>>> proxy = xmlrpc.client.ServerProxy('http://localhost:8000')
>>> proxy.mul
<xmlrpc.client._Method object at 0x03B0C890>
>>> inspect.signature(proxy.mul)
<xmlrpc.client._Method object at 0x03B0CC90>
>>>
Now, according to the documentation, inspect.signature should return a signature or fail, but in this case it returns the actual object, which is misleading at least. This happens because _Method implements a proxy __getattr__, any accessed attribute becoming again a _Method. At the same time, inspect.signature happily uses
try:
obj.__signature__
except AttributeError:
...
to obtain the signature, if present.
The attached patch checks if __signature__ is an actual Signature object. I searched, but couldn't find any, if __signature__ can be anything, so I hope that this approach works. |
|
Date |
User |
Action |
Args |
2014-06-18 12:41:46 | Claudiu.Popa | set | recipients:
+ Claudiu.Popa, yselivanov |
2014-06-18 12:41:45 | Claudiu.Popa | set | messageid: <1403095305.91.0.217669494481.issue21801@psf.upfronthosting.co.za> |
2014-06-18 12:41:45 | Claudiu.Popa | link | issue21801 messages |
2014-06-18 12:41:45 | Claudiu.Popa | create | |
|