From e09bd389a7d94f2bff28290355ced6f6b24436c7 Mon Sep 17 00:00:00 2001 From: Edmund Fokschaner Date: Fri, 6 Dec 2013 20:29:33 -0800 Subject: Fixing bug with jsonrpc._Method caused by debugger Adding __repr__, __str__ and __dir__ to jsonrpc._Method in order to avoid issues with PyCharm debugger due to these functions being called and accessing __getattr__ which mutates the _Method object --- jsonrpclib/jsonrpc.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'jsonrpclib/jsonrpc.py') diff --git a/jsonrpclib/jsonrpc.py b/jsonrpclib/jsonrpc.py index e11939a..c46f1be 100644 --- a/jsonrpclib/jsonrpc.py +++ b/jsonrpclib/jsonrpc.py @@ -282,6 +282,15 @@ class _Method(XML_Method): # The only thing that changes is the name. #return _Method(self.__send, "%s.%s" % (self.__name, name)) + def __repr__(self): + return '<{} "{}">'.format(self.__class__.__name__, self.__name) + + def __str__(self): + return self.__repr__() + + def __dir__(self): + return self.__dict__.keys() + class _Notify(object): def __init__(self, request): self._request = request -- cgit v1.2.1 From 812a6834eec8b8286f4312b3fb8f748da714329d Mon Sep 17 00:00:00 2001 From: Edmund Fokschaner Date: Sat, 26 Sep 2015 17:56:44 -0700 Subject: Revert to xmlrpclib implementation of _Method.__getattr__ --- jsonrpclib/jsonrpc.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'jsonrpclib/jsonrpc.py') diff --git a/jsonrpclib/jsonrpc.py b/jsonrpclib/jsonrpc.py index c46f1be..3812b34 100644 --- a/jsonrpclib/jsonrpc.py +++ b/jsonrpclib/jsonrpc.py @@ -276,11 +276,7 @@ class _Method(XML_Method): return self.__send(self.__name, kwargs) def __getattr__(self, name): - self.__name = '%s.%s' % (self.__name, name) - return self - # The old method returned a new instance, but this seemed wasteful. - # The only thing that changes is the name. - #return _Method(self.__send, "%s.%s" % (self.__name, name)) + return _Method(self.__send, "%s.%s" % (self.__name, name)) def __repr__(self): return '<{} "{}">'.format(self.__class__.__name__, self.__name) -- cgit v1.2.1