From ae8109b60333744f7de96fe6bcc765479266cc86 Mon Sep 17 00:00:00 2001 From: Ari Koivula Date: Wed, 31 Jul 2013 09:41:32 +0300 Subject: [PATCH] [core] Make module reloading call shutdown. - Also make it delete the setup function if one exists. - Remove unnecessary guards from unregister. If the function is on the list, then it is obviously of the correct type. --- reload.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/reload.py b/reload.py index 62b5a922be..bca5f0c541 100644 --- a/reload.py +++ b/reload.py @@ -39,7 +39,7 @@ def f_reload(bot, trigger): old_callables = {} for obj_name, obj in vars(old_module).iteritems(): - if bot.is_callable(obj): + if bot.is_callable(obj) or bot.is_shutdown(obj): old_callables[obj_name] = obj bot.unregister(old_callables) @@ -48,6 +48,10 @@ def f_reload(bot, trigger): # module does not override them. for obj_name in old_callables.keys(): delattr(old_module, obj_name) + + # Also delete the setup function + if hasattr(old_module, "setup"): + delattr(old_module, "setup") # Thanks to moot for prodding me on this path = old_module.__file__