Skip to content

Commit

Permalink
Wean off load_module
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz authored and s0undt3ch committed Aug 25, 2023
1 parent 17a9837 commit e579012
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions salt/loader/lazy.py
Expand Up @@ -747,14 +747,8 @@ def _load_module(self, name):
spec = file_finder.find_spec(mod_namespace)
if spec is None:
raise ImportError()
# TODO: Get rid of load_module in favor of
# exec_module below. load_module is deprecated, but
# loading using exec_module has been causing odd things
# with the magic dunders we pack into the loaded
# modules, most notably with salt-ssh's __opts__.
mod = spec.loader.load_module()
# mod = importlib.util.module_from_spec(spec)
# spec.loader.exec_module(mod)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
# pylint: enable=no-member
sys.modules[mod_namespace] = mod
# reload all submodules if necessary
Expand All @@ -768,14 +762,8 @@ def _load_module(self, name):
)
if spec is None:
raise ImportError()
# TODO: Get rid of load_module in favor of
# exec_module below. load_module is deprecated, but
# loading using exec_module has been causing odd things
# with the magic dunders we pack into the loaded
# modules, most notably with salt-ssh's __opts__.
mod = self.run(spec.loader.load_module)
# mod = importlib.util.module_from_spec(spec)
# spec.loader.exec_module(mod)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
# pylint: enable=no-member
sys.modules[mod_namespace] = mod
except OSError:
Expand Down

0 comments on commit e579012

Please sign in to comment.