From bf68099f2f0ed651df92380472c91d0db408a5f2 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Fri, 15 May 2015 17:01:25 -0500 Subject: [PATCH] ircbot: handle more plugin load failures possibly handle them a bit more cleanly, too, by deleting sys.modules entries --- dr_botzo/ircbot/bot.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dr_botzo/ircbot/bot.py b/dr_botzo/ircbot/bot.py index 5c0edec..bd4eb89 100644 --- a/dr_botzo/ircbot/bot.py +++ b/dr_botzo/ircbot/bot.py @@ -412,6 +412,13 @@ class IRCBot(irc.client.SimpleIRCClient): except ImportError as e: log.error("Error loading '{0:s}'".format(plugin_path)) log.exception(e) + del sys.modules[plugin_path] + if feedback: + self.privmsg(dest, "Plugin '{0:s}' could not be loaded: {1:s}".format(plugin_path, e)) + except AttributeError as e: + log.error("Error loading '{0:s}'".format(plugin_path)) + log.exception(e) + del sys.modules[plugin_path] if feedback: self.privmsg(dest, "Plugin '{0:s}' could not be loaded: {1:s}".format(plugin_path, e))