[issue31385] `import as` does not work when module has same same as parent module

Nick Coghlan report at bugs.python.org
Thu Sep 7 18:29:22 EDT 2017


Nick Coghlan added the comment:

As Serhiy notes, this isn't a bug in the import name resolution, it's a consequence of the wildcard import in bugtest's __init__.py replacing its own "bug.foo" submodule attribute with a reference to "bug.foo.foo".

If the star imports can't be avoided, then a potential workaround is to restore "bugtest.foo" from sys.modules:

    foo = sys.modules[__name__ + ".foo"]

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31385>
_______________________________________


More information about the Python-bugs-list mailing list