classification
Title: absolute import cleanups for Python 3
Type: behavior Stage: test needed
Components: Interpreter Core Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, brett.cannon, eric.smith
Priority: normal Keywords:

Created on 2010-06-28 22:24 by nas, last changed 2012-11-03 18:55 by akuchling. This issue is now closed.

Messages (3)
msg108874 - (view) Author: Neil Schemenauer (nas) Date: 2010-06-28 22:24
It looks like there is a bunch of legacy relative import cruft kicking around in Python 3.  The first thing I noticed is that __import__.__doc__ claims that level=-1 is the default (i.e. use the Python 2 behavior).  A little testing shows that the docs don't lie and __import__ in Python 3 defaults trying a relative import first.

What is the status of implicit relative imports in Python 3?  Can the level=-1 code be removed?
msg108875 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2010-06-28 22:48
Having level=-1 doesn't even work in Python 3 like it did in Python 2 (it seems to just act as if level is 0), so yes the -1 code can be removed. Probably need all values less than 0 to get rounded up to 0 for backwards-compatibility with Python 2.x code which calls __import__ directly.
msg174671 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2012-11-03 18:55
It seems to me that this issue was fixed for Python 3.3 by commit 2dd046be2c88 for #2377, which made importlib the implementation of __import__().  Python/import.c now raises a ValueError if level < 0, and the docstring has been corrected to have 'level=0' as the default.  

I'll therefore close this issue.
History
Date User Action Args
2012-11-03 18:55:14akuchlingsetstatus: open -> closed

nosy: + akuchling
messages: + msg174671

resolution: fixed
2010-06-28 22:48:49brett.cannonsetassignee: brett.cannon ->
2010-06-28 22:48:39brett.cannonsetstage: test needed
2010-06-28 22:48:30brett.cannonsetmessages: + msg108875
versions: + Python 3.2, - Python 3.3
2010-06-28 22:30:48eric.smithsetnosy: + eric.smith
2010-06-28 22:25:10naschemesetassignee: brett.cannon
nosy: + brett.cannon, - nas
2010-06-28 22:24:21nascreate