Skip to content

Commit 8e62df9

Browse files
authored
Fix module reloading incorrectly on exception (#295)
* Restores old module in Bot._modules dict explicitly on exception * Update changelog
1 parent 4b11f78 commit 8e62df9

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Massive documentation updates
1111
- ext.commands
1212
- :func:`Bot.handle_commands` now also invokes on threads / replies
1313
- Cooldowns are now handled correctly per bucket.
14+
- Fix issue with :func:`Bot.reload_module` where module is reloaded incorrectly if exception occurs
1415

1516
- ext.pubsub
1617
- Channel subscription model fixes.

twitchio/ext/commands/bot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ def reload_module(self, name: str):
441441
except Exception as e:
442442
sys.modules.update(modules)
443443
module.prepare(self) # type: ignore
444+
self._modules[name] = module
444445
raise
445446

446447
def add_cog(self, cog: Cog):

0 commit comments

Comments
 (0)