From 64cdc43e5357ac127a0bd0878115844e5507b592 Mon Sep 17 00:00:00 2001 From: Nicolas Vivet Date: Mon, 21 Sep 2020 16:02:23 +0200 Subject: [PATCH] Do not raise when module is loading --- py_mini_racer/py_mini_racer.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/py_mini_racer/py_mini_racer.py b/py_mini_racer/py_mini_racer.py index 155409dc..950252ac 100644 --- a/py_mini_racer/py_mini_racer.py +++ b/py_mini_racer/py_mini_racer.py @@ -47,10 +47,7 @@ def _get_lib_path(name): # In python 3 the extension file name depends on the python version EXTENSION_PATH = _get_lib_path("mini_racer") -if EXTENSION_PATH is None or not os.path.exists(EXTENSION_PATH): - raise RuntimeError("Native library not available at {}".format(EXTENSION_PATH)) - -EXTENSION_NAME = os.path.basename(EXTENSION_PATH) +EXTENSION_NAME = os.path.basename(EXTENSION_PATH) if EXTENSION_PATH is not None else None if sys.version_info[0] < 3: @@ -122,6 +119,8 @@ def _fetch_ext_handle(): if _ext_handle: return _ext_handle + if EXTENSION_PATH is None or not os.path.exists(EXTENSION_PATH): + raise RuntimeError("Native library not available at {}".format(EXTENSION_PATH)) _ext_handle = ctypes.CDLL(EXTENSION_PATH) _ext_handle.mr_init_context.restype = ctypes.c_void_p