Skip to content

Commit 5305a99

Browse files
committed
Since __import__ is not designed for general use, have its docstring point
people towards importlib.import_module(). Closes issue python#7397.
1 parent 1771b54 commit 5305a99

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.2 Alpha 3?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #7397: Mention that importlib.import_module() is probably what someone
14+
really wants to be using in __import__'s docstring.
15+
1316
- Issue #8521: Allow CreateKeyEx, OpenKeyEx, and DeleteKeyEx functions
1417
of winreg to use named arguments.
1518

Python/bltinmodule.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,12 @@ builtin___import__(PyObject *self, PyObject *args, PyObject *kwds)
173173
PyDoc_STRVAR(import_doc,
174174
"__import__(name, globals={}, locals={}, fromlist=[], level=-1) -> module\n\
175175
\n\
176-
Import a module. The globals are only used to determine the context;\n\
177-
they are not modified. The locals are currently unused. The fromlist\n\
176+
Import a module. Because this function is meant for use by the Python\n\
177+
interpreter and not for general use it is better to use\n\
178+
importlib.import_module() to programmatically import a module.\n\
179+
\n\
180+
The globals argument is only used to determine the context;\n\
181+
they are not modified. The locals argument is unused. The fromlist\n\
178182
should be a list of names to emulate ``from name import ...'', or an\n\
179183
empty list to emulate ``import name''.\n\
180184
When importing a module from a package, note that __import__('A.B', ...)\n\

0 commit comments

Comments
 (0)