From e57901290ec46dfe600fd2e7cd4aa3983875f8cd Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Sat, 19 Aug 2023 15:59:38 -0700 Subject: [PATCH] Wean off load_module --- salt/loader/lazy.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/salt/loader/lazy.py b/salt/loader/lazy.py index 6536894bc1d..303636aee8d 100644 --- a/salt/loader/lazy.py +++ b/salt/loader/lazy.py @@ -747,14 +747,8 @@ class LazyLoader(salt.utils.lazy.LazyDict): 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 @@ -768,14 +762,8 @@ class LazyLoader(salt.utils.lazy.LazyDict): ) 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: