Issue 9109: absolute import cleanups for Python 3 (original) (raw)
Issue9109
Created on 2010-06-28 22:24 by nas, last changed 2022-04-11 14:57 by admin. 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) * ![]() |
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) * ![]() |
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 |
2022-04-11 14:57:02 | admin | set | github: 53355 |
2012-11-03 18:55:14 | akuchling | set | status: open -> closednosy: + akuchlingmessages: + resolution: fixed |
2010-06-28 22:48:49 | brett.cannon | set | assignee: brett.cannon -> |
2010-06-28 22:48:39 | brett.cannon | set | stage: test needed |
2010-06-28 22:48:30 | brett.cannon | set | messages: + versions: + Python 3.2, - Python 3.3 |
2010-06-28 22:30:48 | eric.smith | set | nosy: + eric.smith |
2010-06-28 22:25:10 | nascheme | set | assignee: brett.cannonnosy: + brett.cannon, - nas |
2010-06-28 22:24:21 | nas | create |