On Wed, Dec 09, 2020 at 01:56:01PM +0200, Serhiy Storchaka wrote:
> Thank you for good explanation of the problem.
I'm sorry Serhiy, I disagree that this has been a "good explanation of
the problem".
Gregory has not identified any actual bugs caused by this. The only
problem he has identified is that doing this will lead to two separate
module objects from the same file, but as MAL points out, people can do
this intentionally. Gregory hasn't identified any cases where people are
doing this accidentally and having bugs in their code because of that.
He just assumes that they are.
Gregory has still not been 100% clear that he is only talking about
package __init__.py files. I am pretty sure that is what he means, but
the only precise statement he has made is the code
'__init__' in fullname.split('.')
but that will effect non-package files:
__init__.py # not a package, not a special name
and also packages with unusual but legal names:
package/subpackage/__init__/things/stuff.py
> But beginners and non-professionals do not use linters. And from what
> confusion your message caused to commenters in this thread, I changed my
> mind and inclined to agree with you. Yes, it may be worth to add a
> runtime test to the import machinery.
The only person publicly confused by this thread has been me, it is okay
to refer to me by name, you won't embarass me :-)
I am not confused by the alleged problem. The alleged problem is
obvious:
If you import a package __init__.py module directly, the file gets
executed twice, you get two entries in sys.modules and two distinct
module objects.
I am confused by **Gregory's explanation** of the problem.
So far, as far as I can tell from this thread, the only concrete
information we have is that people use this feature and there is at
least one use-case for it. That's not enough to justify breaking
people's code!
I am against changing this behaviour before anyone has identified
*actual bugs* in code caused by it, and before anyone has addressed the
use-case MAL gave for the current behaviour.
--
Steve
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/RSQHU7XWWZ5BFQZCDGJ2WN5YM3B4UYLO/
Code of Conduct: http://python.org/psf/codeofconduct/