Use importlib instead of imp

... because the imp module is deprecated since Python 3.4 .

Change-Id: Id6f2dd16b05090c0409cdab9d77d15eb8ce87ca9
This commit is contained in:
Takashi Kajinami 2021-08-17 08:16:59 +09:00
parent 1224d2b7dd
commit d9c167d070
1 changed files with 6 additions and 2 deletions

View File

@ -14,7 +14,7 @@
# under the License.
import imp
import importlib
import os
from docutils import core
@ -97,7 +97,11 @@ class AnsibleAutoPluginDirective(Directive):
@staticmethod
def load_module(filename):
return imp.load_source('__ansible_module__', filename)
spec = importlib.util.spec_from_file_location('__ansible_module__',
filename)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
@staticmethod
def build_documentation(module):