This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年07月30日 21:39 by Arfrever, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (6) | |||
|---|---|---|---|
| msg166925 - (view) | Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) | Date: 2012年07月30日 21:39 | |
$ 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.
|
|||
| msg166927 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年07月30日 21:46 | |
New changeset 2a4ca86cc2b7 by Brett Cannon in branch 'default': Issue #15508: Fix the docstring for __import__ to not mention negative http://hg.python.org/cpython/rev/2a4ca86cc2b7 |
|||
| msg166928 - (view) | Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) | Date: 2012年07月30日 21:50 | |
What about the suggested change in Doc/library/functions.rst? |
|||
| msg166931 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2012年07月30日 22:35 | |
changest 231d98a38eec has the versionchanged notice. |
|||
| msg166932 - (view) | Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) | Date: 2012年07月30日 22:40 | |
You should probably use *level* instead of 'level'. |
|||
| msg166933 - (view) | Author: Brett Cannon (brett.cannon) * (Python committer) | Date: 2012年07月30日 23:31 | |
changelist d56b647f325a |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:33 | admin | set | github: 59713 |
| 2012年07月30日 23:31:33 | brett.cannon | set | messages: + msg166933 |
| 2012年07月30日 22:40:55 | Arfrever | set | messages: + msg166932 |
| 2012年07月30日 22:35:52 | brett.cannon | set | messages: + msg166931 |
| 2012年07月30日 21:50:41 | Arfrever | set | messages: + msg166928 |
| 2012年07月30日 21:46:45 | brett.cannon | set | status: open -> closed assignee: brett.cannon resolution: fixed stage: resolved |
| 2012年07月30日 21:46:02 | python-dev | set | nosy:
+ python-dev messages: + msg166927 |
| 2012年07月30日 21:39:33 | Arfrever | create | |