From fd1bf224e90baf8edb5a47161823365d0f76ae9f Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Mon, 14 Apr 2025 01:33:51 -0400 Subject: [PATCH] fix(python): catch `BaseException` in wrappers instead of `Exception` (#2163) --- bindings/python/unicorn/unicorn_py2.py | 2 +- bindings/python/unicorn/unicorn_py3/unicorn.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/python/unicorn/unicorn_py2.py b/bindings/python/unicorn/unicorn_py2.py index e93ca962..0b9f560c 100644 --- a/bindings/python/unicorn/unicorn_py2.py +++ b/bindings/python/unicorn/unicorn_py2.py @@ -390,7 +390,7 @@ def _catch_hook_exception(func): """ try: return func(self, *args, **kwargs) - except Exception as e: + except BaseException as e: # If multiple hooks raise exceptions, just use the first one if self._hook_exception is None: self._hook_exception = e diff --git a/bindings/python/unicorn/unicorn_py3/unicorn.py b/bindings/python/unicorn/unicorn_py3/unicorn.py index f08e2914..4248f252 100644 --- a/bindings/python/unicorn/unicorn_py3/unicorn.py +++ b/bindings/python/unicorn/unicorn_py3/unicorn.py @@ -361,7 +361,7 @@ def uccallback(uc: Uc, functype: Type[_CFP]): def wrapper(handle: int, *args, **kwargs): try: return func(uc, *args, **kwargs) - except Exception as e: + except BaseException as e: # If multiple hooks raise exceptions, just use the first one if uc._hook_exception is None: uc._hook_exception = e