X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fpy_plugin.py;fp=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fpy_plugin.py;h=50bfe91ab7f44c5e184b88dbb3046a31134346e1;hp=f1142766e3230152ef08acf458ba3069b58ebac7;hb=0824d69ac4940b8d1277f6eb5dad8860c7f55088;hpb=e21e74d3d22701fa56664af9ddc050e717e88663 diff --git a/src/bindings/python/bt2/bt2/py_plugin.py b/src/bindings/python/bt2/bt2/py_plugin.py index f1142766..50bfe91a 100644 --- a/src/bindings/python/bt2/bt2/py_plugin.py +++ b/src/bindings/python/bt2/bt2/py_plugin.py @@ -123,8 +123,18 @@ def _try_load_plugin_module(path): h.update(path.encode()) module_name = 'bt_plugin_{}'.format(h.hexdigest()) assert module_name not in sys.modules + # try loading the module: any raised exception is catched by the caller - mod = importlib.machinery.SourceFileLoader(module_name, path).load_module() + if sys.version_info < (3, 5): + mod = importlib.machinery.SourceFileLoader(module_name, path).load_module() + else: + import importlib.util + + loader = importlib.machinery.SourceFileLoader(module_name, path) + spec = importlib.util.spec_from_file_location(module_name, path, loader=loader) + mod = importlib.util.module_from_spec(spec) + sys.modules[mod.__name__] = mod + loader.exec_module(mod) # we have the module: look for its plugin info first if not hasattr(mod, '_bt_plugin_info'):