[issue25372] load_module() does not link submodule to parent package

2015-10-14 Thread Martin Panter
Martin Panter added the comment: My use case is for Readline auto-completion, to list submodules of a package given by the user, without importing anything unnecessary. The original code is compatible with Python 2, but I am also writing a patch for 3.6 that wouldn't need that. The original

[issue25372] load_module() does not link submodule to parent package

2015-10-14 Thread R. David Murray
R. David Murray added the comment: Well, once you've loaded the module and added it to the namespace of the parent package, you've imported it. Since import_module is available in 2.7, it sounds like that satisfies your use case. -- ___ Python

[issue25372] load_module() does not link submodule to parent package

2015-10-11 Thread R. David Murray
R. David Murray added the comment: Brett: Martin is calling pkgutil.find_loader, which is not marked as deprecated, and then calling load_module on the returned loader, which apparently does *almost* what he wants but not quite. Martin: maybe you should explain your use case in more detail.

[issue25372] load_module() does not link submodule to parent package

2015-10-11 Thread Brett Cannon
Brett Cannon added the comment: This is entirely on purpose as you're not meant to call load_module() if you want to import code programmatically; that's what importlib.import_module() is for. The load_module() method -- which is kind of deprecated thanks to exec_module() -- is there purely

[issue25372] load_module() does not link submodule to parent package

2015-10-10 Thread Martin Panter
New submission from Martin Panter: The load_module() API adds an entry to sys.modules when loading a submodule, but does not add the submodule as an attribute in the parent package. I am no expert on PEP 302 or the import system, but this feels like a bug to me: >>> import sys, pkgutil >>>

[issue25372] load_module() does not link submodule to parent package

2015-10-10 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis : -- nosy: +Arfrever ___ Python tracker ___

[issue25372] load_module() does not link submodule to parent package

2015-10-10 Thread Martin Panter
Martin Panter added the comment: I don’t think it is a regression. But it is annoying, because my code that works fine for top-level modules and packages happens to screw up the import system for deeper-level module names. -- ___ Python tracker

[issue25372] load_module() does not link submodule to parent package

2015-10-10 Thread Pathangi Jatinshravan
Pathangi Jatinshravan added the comment: Hi, if this is not too critical of a bug, can I be assigned to this issue? -- nosy: +Pathangi Jatinshravan ___ Python tracker

[issue25372] load_module() does not link submodule to parent package

2015-10-10 Thread R. David Murray
R. David Murray added the comment: I'm no expert on pep 302 either, but I'm guessing this is an intentional part of the design. You'll note that updating the namespace is *not* mentioned as one of the things load_module has to do. The update of the namespace is something the import system

[issue25372] load_module() does not link submodule to parent package

2015-10-10 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +brett.cannon, eric.snow, ncoghlan ___ Python tracker ___