From 13b1d6959262c62ca14b42bc06d744ca7d1384f2 Mon Sep 17 00:00:00 2001 From: Bach Ngoc Son Date: Wed, 22 Jan 2020 09:56:11 +0700 Subject: [PATCH 1/2] Fix wrong import logic when loading modules Only load module within package, not all accessible modules Loading all accessible modules causes a bug when an accessible module has a same name with module inside package --- rasa_sdk/executor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rasa_sdk/executor.py b/rasa_sdk/executor.py index 78ec20399..7026e5613 100644 --- a/rasa_sdk/executor.py +++ b/rasa_sdk/executor.py @@ -193,7 +193,9 @@ def _import_submodules( return results = {} - for loader, name, is_pkg in pkgutil.walk_packages(package.__path__): + for loader, name, is_pkg in pkgutil.walk_packages( + package.__path__, package.__name__ + ): full_name = package.__name__ + "." + name results[full_name] = importlib.import_module(full_name) if recursive and is_pkg: From 47603febe6e5016e69184cbb7e81bd916340ce30 Mon Sep 17 00:00:00 2001 From: Bach Ngoc Son Date: Tue, 4 Feb 2020 15:40:59 +0700 Subject: [PATCH 2/2] Fix breaking import --- rasa_sdk/executor.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rasa_sdk/executor.py b/rasa_sdk/executor.py index 7026e5613..f0b1f25a4 100644 --- a/rasa_sdk/executor.py +++ b/rasa_sdk/executor.py @@ -193,10 +193,9 @@ def _import_submodules( return results = {} - for loader, name, is_pkg in pkgutil.walk_packages( - package.__path__, package.__name__ + for loader, full_name, is_pkg in pkgutil.walk_packages( + package.__path__, package.__name__ + "." ): - full_name = package.__name__ + "." + name results[full_name] = importlib.import_module(full_name) if recursive and is_pkg: self._import_submodules(full_name)