[New-bugs-announce] [issue15508] __import__.__doc__ has outdated information about level
Arfrever Frehtes Taifersar Arahesis
report at bugs.python.org
Mon Jul 30 23:39:34 CEST 2012
New submission from Arfrever Frehtes Taifersar Arahesis:
$ python3.2 -c '__import__("os", level=-1)'
$ python3.3 -c '__import__("os", level=-1)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: level must be >= 0
$ python3.3 -c 'print(__import__.__doc__)'
__import__(name, globals={}, locals={}, fromlist=[], level=-1) -> module
Import a module. Because this function is meant for use by the Python
interpreter and not for general use it is better to use
importlib.import_module() to programmatically import a module.
The globals argument is only used to determine the context;
they are not modified. The locals argument is unused. The fromlist
should be a list of names to emulate ``from name import ...'', or an
empty list to emulate ``import name''.
When importing a module from a package, note that __import__('A.B', ...)
returns package A when fromlist is empty, but its submodule B when
fromlist is not empty. Level is used to determine whether to perform
absolute or relative imports. -1 is the original strategy of attempting
both absolute and relative imports, 0 is absolute, a positive number
is the number of parent directories to search relative to the current module.
$
Also please add a ".. versionchanged:: 3.3" note in Doc/library/functions.rst about no longer allowed negative level.
----------
messages: 166925
nosy: Arfrever, brett.cannon
priority: normal
severity: normal
status: open
title: __import__.__doc__ has outdated information about level
versions: Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15508>
_______________________________________
More information about the New-bugs-announce
mailing list