Issue 1690840: xmlrpclib methods submit call on str, repr (original) (raw)

Created on 2007-03-29 19:14 by ghazel, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
xmlrpc_repr.diff schmir,2008-07-03 15:01 implement _Method.__repr__/__str__
Messages (12)
msg31678 - (view) Author: Greg Hazel (ghazel) Date: 2007-03-29 19:14
Notice how trying to print a method causes it to submit the call: Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from xmlrpclib import ServerProxy >>> s = ServerProxy("http://google.com") >>> print s.somecall Traceback (most recent call last): File "", line 1, in File "c:\python25\lib\xmlrpclib.py", line 1147, in __call__ return self.__send(self.__name, args) File "c:\python25\lib\xmlrpclib.py", line 1437, in __request verbose=self.__verbose File "c:\python25\lib\xmlrpclib.py", line 1191, in request headers xmlrpclib.ProtocolError: <ProtocolError for google.com/RPC2: 501 Not Implemented Similarly: >>> f = s.somecall >>> locals() {'f': Traceback (most recent call last): File "", line 1, in File "c:\python25\lib\xmlrpclib.py", line 1147, in __call__ return self.__send(self.__name, args) File "c:\python25\lib\xmlrpclib.py", line 1437, in __request verbose=self.__verbose File "c:\python25\lib\xmlrpclib.py", line 1191, in request headers xmlrpclib.ProtocolError: <ProtocolError for google.com/RPC2: 501 Not Implemented>
msg31679 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-03-30 02:59
What would you rather seem them print?
msg31680 - (view) Author: Greg Hazel (ghazel) Date: 2007-04-04 06:45
This would be reasonable: >>> from xmlrpclib import ServerProxy >>> s = ServerProxy("http://google.com") >>> print s.somecall <xmlrpclib._Method object at 0x00C08470> Similarly: >>> f = s.somecall >>> locals() {'f': <xmlrpclib._Method object at 0x00BA8030>, '__builtins__': <module '__built in__' (built-in)>, 's': <ServerProxy for google.com/RPC2>, '__name__': '__main__ ', 'ServerProxy': <class xmlrpclib.ServerProxy at 0x00C61AE0>, '__doc__': None} Bonus points for: <xmlrpclib _Method somecall of <ServerProxy for google.com/RPC2>>
msg31681 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-04-04 15:10
Fredrik, you originally wrote xmlrpclib: any objections to stringifying _Method objects to something like "<xmlrpclib _Method somecall at 0x4636e346>"?
msg55815 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2007-09-11 06:23
I'm trying to think of a reason for actually providing __repr__ over RPC, but I cannot find any. Not quite as sure about __str__, though; I suggest adding a __repr__ method, but leaving the rest as is.
msg55817 - (view) Author: Greg Hazel (ghazel) Date: 2007-09-11 06:35
How about making ServerProxy a new-style class?
msg69203 - (view) Author: Ralf Schmitt (schmir) Date: 2008-07-03 15:01
I think __str__ should also be implemented. I'm attaching a patch with unittests against current trunk.
msg69204 - (view) Author: Ralf Schmitt (schmir) Date: 2008-07-03 15:04
this is how it looks: ~/pydev/trunk/ python ralf@red ok Python 2.6b1+ (trunk, Jul 3 2008, 12:43:37) [GCC 4.3.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from xmlrpclib import Server >>> Server("http://localhost:8000").doit <xmlrpclib._Method doit <bound method ServerProxy.__request of <ServerProxy for localhost:8000/RPC2>>>
msg116659 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-09-17 12:51
This has been fixed in py3k but not 2.7. Is it worth backporting the change?
msg176124 - (view) Author: anatoly techtonik (techtonik) Date: 2012-11-22 20:45
I'd say this one worthy to be backported.
msg377107 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-09-18 11:37
Python 3.10.0a0 (heads/master:6595cb0af4, Sep 18 2020, 12:33:44) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import xmlrpc.client >>> s = xmlrpc.client.ServerProxy("http://google.com") >>> print(s.somecall) <xmlrpc.client._Method object at 0x00F5AEC8> >>>
msg377108 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2020-09-18 11:37
Since this was fixed in python 3, and the backport to python 2 is no longer relevant, I think this issue can now be closed.
History
Date User Action Args
2022-04-11 14:56:23 admin set github: 44785
2020-09-18 11:43:26 serhiy.storchaka set status: open -> closedresolution: fixed -> out of date
2020-09-18 11:37:13 iritkatriel set messages: +
2020-09-18 11:37:07 iritkatriel set status: pending -> opennosy: + iritkatrielmessages: +
2016-01-20 09:57:45 serhiy.storchaka set status: open -> pending
2014-02-03 19:06:31 BreamoreBoy set nosy: - BreamoreBoy
2012-11-22 20:45:22 techtonik set status: pending -> opennosy: + techtonikmessages: +
2010-09-17 12:51:54 BreamoreBoy set status: open -> pendingtype: behaviorversions: + Python 3.1, Python 2.7, Python 3.2nosy: + BreamoreBoymessages: + resolution: fixedstage: resolved
2008-07-03 15:04:29 schmir set messages: +
2008-07-03 15:01:46 schmir set files: + xmlrpc_repr.diffkeywords: + patchmessages: +
2008-07-02 17:31:14 schmir set nosy: + schmir
2007-09-11 06:35:42 ghazel set messages: +
2007-09-11 06:23:11 effbot set assignee: effbot -> collinwintermessages: +
2007-03-29 19:14:04 ghazel create