From 5678d7dd988056d4974ddfe342b7037c2b723c71 Mon Sep 17 00:00:00 2001 From: gugug Date: Sun, 30 Aug 2020 22:30:33 +0800 Subject: [PATCH] Use importlib to take place of imp module The imp module is deprecated[1] since version 3.4, use importlib to instead [1]: https://docs.python.org/3/library/imp.html Change-Id: I80880417abc8955a53fdfcab93f27b4bef2ddb11 --- doc/source/_exts/ansible-autodoc.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/source/_exts/ansible-autodoc.py b/doc/source/_exts/ansible-autodoc.py index e85b3cc4a..5d61b8c16 100644 --- a/doc/source/_exts/ansible-autodoc.py +++ b/doc/source/_exts/ansible-autodoc.py @@ -14,7 +14,7 @@ # under the License. -import imp +import importlib.util import os from docutils import core @@ -93,7 +93,12 @@ class AnsibleAutoPluginDirective(Directive): @staticmethod def load_module(filename): - return imp.load_source('__ansible_module__', filename) + module_spec = importlib.util.spec_from_file_location( + '__ansible_module__', filename + ) + module = importlib.util.module_from_spec(module_spec) + module_spec.loader.exec_module(module) + return module @staticmethod def build_documentation(module):