We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a518c6c commit 5315a95Copy full SHA for 5315a95
redbot/core/bot.py
@@ -1630,15 +1630,20 @@ async def load_extension(self, spec: ModuleSpec):
1630
1631
lib = module_from_spec(spec)
1632
sys.modules[name] = lib
1633
- spec.loader.exec_module(lib)
+ try:
1634
+ spec.loader.exec_module(lib)
1635
+ except Exception:
1636
+ del sys.modules[name]
1637
+ raise
1638
1639
if not hasattr(lib, "setup"):
1640
del lib
1641
raise discord.ClientException(f"extension {name} does not have a setup function")
1642
1643
try:
1644
await lib.setup(self)
- except Exception as e:
1645
1646
1647
await self._remove_module_references(lib.__name__)
1648
await self._call_module_finalizers(lib, name)
1649
raise
0 commit comments