Steven Barker added the comment:
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
----------
nosy: +Steven.Barker
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue23447>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com