Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 722d3ae

Browse files
committed
Issue #15508: Fix the docstring for __import__ to not mention negative
'level' values and set its document default value to 0. Thanks to Arfrever Frehtes Taifersar Arahesis for filing the bug.
1 parent 504ba31 commit 722d3ae

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ What's New in Python 3.3.0 Beta 2?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #15508: Fix the docstring for __import__ to have the proper default
14+
value of 0 for 'level' and to not mention negative levels since they are
15+
not supported.
16+
1317
- Issue #15425: Eliminated traceback noise from more situations involving
1418
importlib
1519

Python/bltinmodule.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ builtin___import__(PyObject *self, PyObject *args, PyObject *kwds)
195195
}
196196

197197
PyDoc_STRVAR(import_doc,
198-
"__import__(name, globals={}, locals={}, fromlist=[], level=-1) -> module\n\
198+
"__import__(name, globals={}, locals={}, fromlist=[], level=0) -> module\n\
199199
\n\
200200
Import a module. Because this function is meant for use by the Python\n\
201201
interpreter and not for general use it is better to use\n\
@@ -208,8 +208,7 @@ empty list to emulate ``import name''.\n\
208208
When importing a module from a package, note that __import__('A.B', ...)\n\
209209
returns package A when fromlist is empty, but its submodule B when\n\
210210
fromlist is not empty. Level is used to determine whether to perform \n\
211-
absolute or relative imports. -1 is the original strategy of attempting\n\
212-
both absolute and relative imports, 0 is absolute, a positive number\n\
211+
absolute or relative imports. 0 is absolute while a positive number\n\
213212
is the number of parent directories to search relative to the current module.");
214213

215214

0 commit comments

Comments
 (0)