[issue42273] Using LazyLoader leads to AttributeError

2020-11-12 Thread Brett Cannon
Brett Cannon added the comment: You can ignore the half sentence. I was contemplating closing this issue when I decided to leave it open in case someone wanted to propose something and another core dev wanted to take it on. But everything is working as I expect it to and you may want to do y

[issue42273] Using LazyLoader leads to AttributeError

2020-11-12 Thread Brett Cannon
Change by Brett Cannon : -- nosy: -brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail

[issue42273] Using LazyLoader leads to AttributeError

2020-11-12 Thread E. Paine
E. Paine added the comment: Sorry Brett to readd you to the nosy for this, but we only got half a sentence in msg380718 (which is surely not what you intended?). While I agree with you that this is not a bug, I do feel at least a note in the docs would be helpful to explain the implications

[issue42273] Using LazyLoader leads to AttributeError

2020-11-10 Thread Kevin Keating
Kevin Keating added the comment: One possible solution here would be to update the documentation at https://github.com/python/cpython/blob/master/Doc/library/importlib.rst#implementing-lazy-imports to either note the limitation or to modify the lazy_import function so that it adds the module

[issue42273] Using LazyLoader leads to AttributeError

2020-11-10 Thread Kevin Keating
Kevin Keating added the comment: Brett, what do you mean by "the way import works"? Is the difference between using LazyLoader and using a normal import intentional? -- status: -> open ___ Python tracker

[issue42273] Using LazyLoader leads to AttributeError

2020-11-10 Thread Brett Cannon
Change by Brett Cannon : -- nosy: -brett.cannon resolution: not a bug -> status: closed -> ___ Python tracker ___ ___ Python-bugs

[issue42273] Using LazyLoader leads to AttributeError

2020-11-10 Thread Brett Cannon
Brett Cannon added the comment: The way import works, -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ __

[issue42273] Using LazyLoader leads to AttributeError

2020-11-10 Thread E. Paine
E. Paine 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

[issue42273] Using LazyLoader leads to AttributeError

2020-11-09 Thread Kevin Keating
Kevin Keating added the comment: My colleague just tested this on Mac and confirms that the bug also occurs there using Python 3.8.3. -- ___ Python tracker ___ __

[issue42273] Using LazyLoader leads to AttributeError

2020-11-09 Thread Kevin Keating
Kevin Keating added the comment: An __init__.py shouldn't be necessary. If I comment out the 'b = lazy_import("foo.b")' line in a.py (i.e. disable the lazy import), then the print statement works correctly as written without any other changes. Also, I double checked with the colleague who o

[issue42273] Using LazyLoader leads to AttributeError

2020-11-07 Thread E. Paine
E. Paine added the comment: Just checking: is this not because the lazy import should be in `__init__.py`? (the code provided works fine with `a.b.my_function` on my system) -- components: +Interpreter Core -Library (Lib) nosy: +brett.cannon, epaine, eric.snow, ncoghlan type: -> beha

[issue42273] Using LazyLoader leads to AttributeError

2020-11-05 Thread Kevin Keating
New submission from Kevin Keating : Steps to reproduce: Create the following three files (or download the attached zip file, which contains these files): main.py import foo from foo import a from foo import b print(foo.b.my_function()) foo/a.py import importlib.util