[issue43477] from x import * behavior inconsistent between module types.

Thomas report at bugs.python.org
Sat Mar 13 21:05:39 EST 2021


Thomas <kaori.hinata at gmail.com> added the comment:

I've spent a bit of time building (and rebuilding) Python 3.9 with a modified `Lib/importlib/_bootstrap.py`/regenerated `importlib.h` to give me some extra logging, and believe the answer I was looking for is `_find_and_load_unlocked`. `_find_and_load_unlocked` appears to load the module in question, and always attach it to the parent regardless of the contents of `fromlist` (`_find_and_load_unlocked` isn't even aware of `fromlist`.) The only real condition seems to be "is there a parent/are we in a package?". `Lib/importlib/_bootstrap.py` is pretty sparsely documented so it's not immediately obvious whether or not some other piece of `importlib` depends on this behavior. If the author is known, then they may be able to give some insight into why the decision was made, and what the best solution would be?

----------

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


More information about the Python-bugs-list mailing list