[Python-Dev] status of absolute_import w/ python 2.7

Brett Cannon brett at python.org
Wed Jul 13 05:41:28 CEST 2011


On Fri, Jul 8, 2011 at 06:51, Sylvain Thénault
<sylvain.thenault at logilab.fr>wrote:

> Hi there,
>
> the documentation state that absolute_import feature is the default
> behaviour with python 2.7, though it seems that it behave differently
> with the __future__ import :
>
> $ cat package/__init__.py
>
> import subpackage
>
> $ python2.7
> Python 2.7.1+ (default, Apr 20 2011, 22:33:39)
> [GCC 4.5.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import package
> >>>
>
> $ cat package/__init__.py
>
> from __future__ import absolute_import
> import subpackage
>
> $ python2.7
> Python 2.7.1+ (default, Apr 20 2011, 22:33:39)
> [GCC 4.5.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import package
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "package/__init__.py", line 23, in <module>
>    import subpackage
> ImportError: No module named subpackage
>

So are you claiming that the import of 'package' w/o the __future__
statement actually succeeds even though there is no package.subpackage
module? Obviously that would be a flat-out bug, but I just double-checked my
sanity and that does nto work with a CPython 2.7 checkout.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110712/164e3dd0/attachment.html>


More information about the Python-Dev mailing list