Skip to content

Commit

Permalink
Wean off load_module
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed Aug 22, 2023
1 parent ba433a7 commit e458dd4
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions salt/loader/lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,14 +734,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 @@ -755,14 +749,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 e458dd4

Please sign in to comment.