Author Steven.Barker
Recipients Steven.Barker, antox, brett.cannon
Date 2015-02-13.01:03:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1423789391.2.0.199929826418.issue23447@psf.upfronthosting.co.za>
In-reply-to
Content
This issue is a special case of the problem discussed in issue 992389, that modules within packages are not added to the package dictionary until they are fully loaded, which breaks circular imports in the form "from package import module".

The consensus on that issue is that it doesn't need to be fixed completely, given the partial fix from issue 17636. I think the current issue is a corner case that was not covered by the fix, but which probably should be fixed as well, for consistency. The fix so far has made imports that name the module work, even though the module objects are still not placed into the package's namespace yet (this is why Antonio's last example works in the newly released 3.5a1, though not in previous versions). Wildcard imports however still fail.

Can the fix be expanded to cover wildcard imports as well? I know, we're heaping up two kinds of usually-bad code (wildcard imports and circular imports) on top of one another, but still, the failure is very unexpected to anyone who's not read the bug reports.

I don't know my way around the import system at all yet, so I'm not going to be capable of writing up a patch immediately, but if there's any interest at all, and nobody more knowledgeable gets to it first I might see what I can learn and try to put together something.

Here's a more concise example of the issue:


package/__init__.py:

    __all__ = ["module"]


package/module.py:

    from . import module # this works in 3.5a1, thanks to the fix from issue 17636
    from . import *      # this still fails
History
Date User Action Args
2015-02-13 01:03:11Steven.Barkersetrecipients: + Steven.Barker, brett.cannon, antox
2015-02-13 01:03:11Steven.Barkersetmessageid: <1423789391.2.0.199929826418.issue23447@psf.upfronthosting.co.za>
2015-02-13 01:03:11Steven.Barkerlinkissue23447 messages
2015-02-13 01:03:10Steven.Barkercreate