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/highlighting.py
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/highlighting.py')
-rw-r--r--sphinx/highlighting.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py
index b4e63209f..977b71f28 100644
--- a/sphinx/highlighting.py
+++ b/sphinx/highlighting.py
@@ -11,6 +11,7 @@
import html
import warnings
from functools import partial
+from importlib import import_module
from pygments import highlight
from pygments.filters import ErrorToken
@@ -92,7 +93,7 @@ class PygmentsBridge:
return NoneStyle
elif '.' in stylename:
module, stylename = stylename.rsplit('.', 1)
- return getattr(__import__(module, None, None, ['__name__']), stylename)
+ return getattr(import_module(module), stylename)
else:
return get_style_by_name(stylename)