From fc22d288be30d8cfab7b03c2fdf23f3e03d3dffc Mon Sep 17 00:00:00 2001 From: khazhyk Date: Tue, 4 Jul 2017 19:13:27 -0700 Subject: [PATCH] [commands] unload cog submodules When unloading cogs, currently we do not remove submodules from sys.modules, meaning they will not be reloaded. Removing here makes new imports reload from file. Of course, any already imported modules will still hold a reference to the old module, since they will not re-import it, and will not be forcably unloaded. --- discord/ext/commands/bot.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py index 85b8d1341..34ab30e2c 100644 --- a/discord/ext/commands/bot.py +++ b/discord/ext/commands/bot.py @@ -768,6 +768,9 @@ class BotBase(GroupMixin): del lib del self.extensions[name] del sys.modules[name] + for module in list(sys.modules.keys()): + if _is_submodule(lib_name, module): + del sys.modules[module] # command processing