E. Paine <paineeli...@gmail.com> added the comment:

In short, the module isn't being added to the package's namespace because we 
are directly modifying sys.modules (hence why the behaviour would be the same 
if we imported using `import foo.b` as `from foo import b`).

I personally prefer to use the metapath instead of modifying sys.modules but I 
agree that the given example should work when the lazy import is not in 
`__init__.py`. The other solution is to modify the `LazyLoader` class to 
explicitly add the lazy module to the package's namespace (opinions?).

----------
versions: +Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42273>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to