Catch import warnings in a common location for both get() and all()

Potential solution for #12979
pull/13117/head
James Cammarata 9 years ago
parent 9f0c2cfda5
commit 0fc187893d

@ -307,6 +307,8 @@ class PluginLoader:
if name in sys.modules:
# See https://github.com/ansible/ansible/issues/13110
return sys.modules[name]
with warnings.catch_warnings():
warnings.simplefilter("ignore", RuntimeWarning)
with open(path, 'r') as module_file:
module = imp.load_source(name, path, module_file)
return module
@ -344,8 +346,6 @@ class PluginLoader:
continue
if path not in self._module_cache:
with warnings.catch_warnings():
warnings.simplefilter("ignore", RuntimeWarning)
self._module_cache[path] = self._load_module_source(name, path)
if kwargs.get('class_only', False):

Loading…
Cancel
Save