This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kaorihinata
Recipients kaorihinata
Date 2021-03-12.00:40:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615509638.08.0.549124406797.issue43477@roundup.psfhosted.org>
In-reply-to
Content
I'm looking for clarification as to how `from x import *` should operate when importing file/directory-based modules versus when importing a sub-module from within a directory-based module.

While looking into a somewhat related issue with pylint, I noticed that `from x import *` appears to behave inconsistently when called from within a directory-based module on a sub-module. Whereas normally `from x import *` intentionally does not cause `x` to be added to the current namespace, when called within a directory-based module to import from a sub-module (so, `from .y import *` in an `__init__.py`, for example), the sub-module (let's say, `y`) *does* end up getting added to the importing namespace. From what I can tell, this should not be happening. If this oddity has been documented somewhere, I may have just missed it, so please let me know if it has been.

This inconsistency is actually setting off pylint (and confusing its AST handling code) when you use the full path to reference any member of the `asyncio.subprocess` submodule (for example, `asyncio.subprocess.Process`) because, according to `asyncio`'s `__init__.py` file, no explicit import of the `subprocess` sub-module ever occurs, and yet you can draw the entire path all the way to it, and its members. I've attached a generic example of the different behaviors (tested with Python 3.9) using simple modules, including a demonstration of the sub-module import.

Thomas
History
Date User Action Args
2021-03-12 00:40:38kaorihinatasetrecipients: + kaorihinata
2021-03-12 00:40:38kaorihinatasetmessageid: <1615509638.08.0.549124406797.issue43477@roundup.psfhosted.org>
2021-03-12 00:40:37kaorihinatalinkissue43477 messages
2021-03-12 00:40:36kaorihinatacreate