Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2019-08-17 21:45:39 +0300
committerJon Dufresne <jon.dufresne@gmail.com>2019-08-17 21:45:39 +0300
commitecb1e763ad0917ac37061b648a53793a687cc760 (patch)
treeda14d950c57dd801c1ac2d01995eaec574dcff4e /sphinx/search
parentbf573ae1454fd0a6f5bbcb316fbabc42a056da3a (diff)
Switch uses of __import__ to importlib.get_module()
The Python docs for __import__ recommend using importlib.get_module(). https://docs.python.org/3/library/functions.html#__import__ > Note: This is an advanced function that is not needed in everyday > Python programming, unlike importlib.import_module(). As importlib.get_module() uses the Python module cache and returns the module, this also allows simplifying many module cache checks of use of sys.modules. importlib.get_module() has been available since Python 3.3.
Diffstat (limited to 'sphinx/search')
-rw-r--r--sphinx/search/__init__.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/sphinx/search/__init__.py b/sphinx/search/__init__.py
index 1b4f7ea59..22ba14d40 100644
--- a/sphinx/search/__init__.py
+++ b/sphinx/search/__init__.py
@@ -11,6 +11,7 @@ import html
import pickle
import re
import warnings
+from importlib import import_module
from os import path
from docutils import nodes
@@ -278,8 +279,7 @@ class IndexBuilder:
self.lang = SearchEnglish(options) # type: SearchLanguage
elif isinstance(lang_class, str):
module, classname = lang_class.rsplit('.', 1)
- lang_class = getattr(__import__(module, None, None, [classname]),
- classname)
+ lang_class = getattr(import_module(module), classname)
self.lang = lang_class(options)
else:
# it's directly a class (e.g. added by app.add_search_language)