From 32abe2dd041a6d4d59c7a149d5b53fc34e790ee4 Mon Sep 17 00:00:00 2001 From: vrde Date: Mon, 16 Sep 2013 21:26:55 +0200 Subject: [PATCH 1/2] Remove eval from from run_hook small improvement to remove eval using builtin function `getattr`. --- gui/gui_classic/main_window.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gui/gui_classic/main_window.py b/gui/gui_classic/main_window.py index 36085ba3..7cddbbfc 100644 --- a/gui/gui_classic/main_window.py +++ b/gui/gui_classic/main_window.py @@ -466,10 +466,11 @@ class ElectrumWindow(QMainWindow): for p in self.plugins: if not p.is_enabled(): continue - try: - f = eval('p.'+name) - except: - continue + + f = getattr(p, name, None) + if not callable(f): + return + try: apply(f, args) except: From f0f3dc24e12d863a9a45524808f461e09e90cf66 Mon Sep 17 00:00:00 2001 From: vrde Date: Tue, 17 Sep 2013 00:23:13 +0200 Subject: [PATCH 2/2] apply function directly unpacking argument list --- gui/gui_classic/main_window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/gui_classic/main_window.py b/gui/gui_classic/main_window.py index 7cddbbfc..261b8e46 100644 --- a/gui/gui_classic/main_window.py +++ b/gui/gui_classic/main_window.py @@ -472,7 +472,7 @@ class ElectrumWindow(QMainWindow): return try: - apply(f, args) + f(*args) except: print_error("Plugin error") traceback.print_exc(file=sys.stdout)