summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-08-23 14:58:49 (GMT)
committerBrett Cannon <brett@python.org>2013-08-23 14:58:49 (GMT)
commitf5ebd264032fbcb07a41a49031c2281f81c9a814 (patch)
tree3befe71dd78d52f0bdbe0222f9eed08ef7f0bba3 /Doc/library
parent01e75a699d2fd8e9dbfa428412da2a7d1b0af257 (diff)
downloadcpython-f5ebd264032fbcb07a41a49031c2281f81c9a814.zip
cpython-f5ebd264032fbcb07a41a49031c2281f81c9a814.tar.gz
cpython-f5ebd264032fbcb07a41a49031c2281f81c9a814.tar.bz2
Emphasize that people should not override __import__.
With importlib getting used more and more, changing __import__ will not work as well as people used to hope as it will potentially bypass importers, etc. It also will not work with importlib.import_module() as it uses "importlib.__import__" (i.e. importlib's implementation of import) directly and not builtins.__import__.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/functions.rst9
1 files changed, 5 insertions, 4 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index b94c434..c3fff31 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1451,10 +1451,11 @@ are always available. They are listed here in alphabetical order.
This function is invoked by the :keyword:`import` statement. It can be
replaced (by importing the :mod:`builtins` module and assigning to
``builtins.__import__``) in order to change semantics of the
- :keyword:`import` statement, but nowadays it is usually simpler to use import
- hooks (see :pep:`302`) to attain the same goals. Direct use of
- :func:`__import__` is entirely discouraged in favor of
- :func:`importlib.import_module`.
+ :keyword:`import` statement, but doing so is **strongly** discouraged as it
+ is usually simpler to use import hooks (see :pep:`302`) to attain the same
+ goals and does not cause issues with code which assumes the default import
+ implementation is in use. Direct use of :func:`__import__` is also
+ discouraged in favor of :func:`importlib.import_module`.
The function imports the module *name*, potentially using the given *globals*
and *locals* to determine how to interpret the name in a package context.