From 5a1a2e6c18280cf505bacc051e9b539bdd5fcf0c Mon Sep 17 00:00:00 2001 From: mathieui Date: Fri, 23 Aug 2019 12:31:20 +0200 Subject: [PATCH] Add a "passthrough" parameter for calls through the safetymetaclass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So errors don’t get caught --- poezio/plugin.py | 6 ++++++ poezio/plugin_e2ee.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/poezio/plugin.py b/poezio/plugin.py index c3d10b38..61e0ea87 100644 --- a/poezio/plugin.py +++ b/poezio/plugin.py @@ -75,9 +75,12 @@ class SafetyMetaclass(type): @staticmethod def safe_func(f): def helper(*args, **kwargs): + passthrough = kwargs.pop('passthrough', False) try: return f(*args, **kwargs) except: + if passthrough: + raise if inspect.stack()[1][1] == inspect.getfile(f): raise elif SafetyMetaclass.core: @@ -86,9 +89,12 @@ class SafetyMetaclass(type): 'Error') return None async def async_helper(*args, **kwargs): + passthrough = kwargs.pop('passthrough', False) try: return await f(*args, **kwargs) except: + if passthrough: + raise if inspect.stack()[1][1] == inspect.getfile(f): raise elif SafetyMetaclass.core: diff --git a/poezio/plugin_e2ee.py b/poezio/plugin_e2ee.py index 75ce6fd0..ab644f7a 100644 --- a/poezio/plugin_e2ee.py +++ b/poezio/plugin_e2ee.py @@ -245,9 +245,9 @@ class E2EEPlugin(BasePlugin): # Call the enabled encrypt method func = self._enabled_tabs[jid] if iscoroutinefunction(func): - await func(message, tab) + await func(message, tab, passthrough=True) else: - func(message, tab) + func(message, tab, passthrough=True) if has_body: # Only add EME tag if the message has a body.