@@ -2697,10 +2697,10 @@ def _reload_module(
26972697 _LOGGER .info ("Reloading %s" , module_path )
26982698
26992699 old_loaders = _get_loaders (old_module , module_path )
2700- # We assert that the old module has unloaders early to avoid unnecessarily
2701- # importing the new module.
2702- if not any ( loader . has_unload for loader in old_loaders ):
2703- raise errors . ModuleMissingUnloaders ( f"Didn't find any unloaders in old { module_path } " , module_path )
2700+ modules_dict . pop ( module_path )
2701+ with _WrapLoadError ( errors . FailedModuleUnload , module_path ):
2702+ # This will never raise MissingLoaders as we assert this earlier
2703+ self . _call_unloaders ( module_path , old_loaders )
27042704
27052705 module = yield load_module
27062706
@@ -2711,10 +2711,6 @@ def _reload_module(
27112711 if not any (loader .has_load for loader in loaders ):
27122712 raise errors .ModuleMissingLoaders (f"Didn't find any loaders in new { module_path } " , module_path )
27132713
2714- with _WrapLoadError (errors .FailedModuleUnload , module_path ):
2715- # This will never raise MissingLoaders as we assert this earlier
2716- self ._call_unloaders (module_path , old_loaders )
2717-
27182714 try :
27192715 # This will never raise MissingLoaders as we assert this earlier
27202716 self ._call_loaders (module_path , loaders )
0 commit comments