From 074cddf11fcbb35b197bef3653907bee06f8da7e Mon Sep 17 00:00:00 2001 From: pyrz6x9 <52868058+pyrz6x9@users.noreply.github.com> Date: Fri, 1 May 2020 17:52:06 +0200 Subject: [PATCH] Fixed exception when importing unknown plugin and would cause either a double plugin in plugins list or raise an exception when appending local variable 'module' because it was referenced before assignment after try exception was raised. --- honeybot/hbotapi/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/honeybot/hbotapi/main.py b/honeybot/hbotapi/main.py index dc8144f..509f3da 100644 --- a/honeybot/hbotapi/main.py +++ b/honeybot/hbotapi/main.py @@ -143,10 +143,10 @@ def load_plugins(self, plugins_to_load): print("loading plugin:", file) try: module = importlib.import_module("plugins.{}".format(file)) + obj = module + self.plugins.append(obj) except ModuleNotFoundError as e: logger.warning(f"{file}: module import error, skipped' {e}") - obj = module - self.plugins.append(obj) logger.info("Loaded plugins...")