electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit ba33bc4ad85e759d67093fcc1edae51e6ab5a692
parent fa33d1880c572820d69c02536242f2b0475e502c
Author: SomberNight <somber.night@protonmail.com>
Date:   Wed, 19 Dec 2018 02:10:47 +0100

plugins: fix hook/attr name collision in close()

Revealer plugin has method "password_dialog"
"password_dialog" is also a hook name, but revealer.password_dialog is not a hook

Diffstat:
Melectrum/plugin.py | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/electrum/plugin.py b/electrum/plugin.py @@ -251,11 +251,16 @@ class BasePlugin(PrintError): def close(self): # remove self from hooks - for k in dir(self): - if k in hook_names: - l = hooks.get(k, []) - l.remove((self, getattr(self, k))) - hooks[k] = l + for attr_name in dir(self): + if attr_name in hook_names: + # found attribute in self that is also the name of a hook + l = hooks.get(attr_name, []) + try: + l.remove((self, getattr(self, attr_name))) + except ValueError: + # maybe attr name just collided with hook name and was not hook + continue + hooks[attr_name] = l self.parent.close_plugin(self) self.on_close()