move "dont unload core modules" to where it won't affect reloads

This commit is contained in:
jesopo 2020-01-28 16:25:15 +00:00
parent 63d2c16954
commit 67aa90fc94

View file

@ -354,13 +354,14 @@ class ModuleManager(object):
if not name in self.modules: if not name in self.modules:
raise ModuleNotLoadedException(name) raise ModuleNotLoadedException(name)
loaded_module = self.modules[name] loaded_module = self.modules[name]
if loaded_module.is_core:
raise ModuleCannotUnloadException("cannot unload core modules")
self._unload_module(loaded_module) self._unload_module(loaded_module)
del self.modules[loaded_module.name] del self.modules[loaded_module.name]
def _unload_module(self, loaded_module: LoadedModule): def _unload_module(self, loaded_module: LoadedModule):
if loaded_module.is_core:
raise ModuleCannotUnloadException("cannot unload core modules")
if hasattr(loaded_module.module, "unload"): if hasattr(loaded_module.module, "unload"):
try: try:
loaded_module.module.unload() loaded_module.module.unload()