[issue42564] "from .__init__ import ..." syntax imports a duplicate module

2020-12-07 Thread Gregory Szorc
Gregory Szorc added the comment: Who uses this syntax? https://github.com/search?l=Python&q=%22from+.__init__+import%22&type=Code says a lot of random code, surprisingly/sadly. As for python-ideas, thanks for the suggestion: I may very well craft an email! -- __

[issue42564] "from .__init__ import ..." syntax imports a duplicate module

2020-12-07 Thread Brett Cannon
Brett Cannon added the comment: You could propose your backwards-incompatible proposals on python-ideas, Greg, and see if you get any uptake. -- ___ Python tracker ___ __

[issue42564] "from .__init__ import ..." syntax imports a duplicate module

2020-12-04 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What is the problem? What real code imports __init__? -- ___ Python tracker ___ ___ Python-bugs

[issue42564] "from .__init__ import ..." syntax imports a duplicate module

2020-12-04 Thread Gregory Szorc
Gregory Szorc added the comment: I worked around this in PyOxidizer by stripping a trailing `.__init__` from module names when resolving the indexed resource data. This allows the import to work since it can find the data now, but it also preserves the double module object, which isn't ideal

[issue42564] "from .__init__ import ..." syntax imports a duplicate module

2020-12-04 Thread Brett Cannon
Brett Cannon added the comment: I agree with Serhiy; don't do this. The only way we could fix this would be to always set a `__init__` module for every package implicitly, but then that would break anyone who wanted to clear out a package in sys.modules as the `__init__` reference in sys.mod

[issue42564] "from .__init__ import ..." syntax imports a duplicate module

2020-12-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Other example is: >>> import sys >>> import xml >>> import xml.__init__ >>> sys.modules['xml'] >>> sys.modules['xml.__init__'] >>> sys.modules['xml'] is sys.modules['xml.__init__'] False I'm not sure we should do anything about it other than say "Don't do

[issue42564] "from .__init__ import ..." syntax imports a duplicate module

2020-12-03 Thread Gregory Szorc
New submission from Gregory Szorc : (Rereporting from https://github.com/indygreg/PyOxidizer/issues/317.) $ mkdir foo $ cat > foo/__init__.py < test = True > EOF $ cat > foo/bar.py < from .__init__ import test > EOF $ python3.9 Python 3.9.0 (default, Nov 1 2020, 22:40:00) [GCC 10.2.0] on linux