<div dir="ltr">My preference is (1), revert. You have to understand how sys.modules works before you can change it, and if you waste time debugging your mistake, so be it. I think the sys.py proposal is the wrong way to fix the mistake you made there.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 13, 2017 at 4:00 PM, Eric Snow <span dir="ltr"><<a href="mailto:ericsnowcurrently@gmail.com" target="_blank">ericsnowcurrently@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, Sep 12, 2017 at 9:30 PM, Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br>
> I find this a disturbing trend.<br>
<br>
</span>Which trend? Moving away from "consenting adults"? In the case of<br>
sys.modules, the problem is that assigning a bogus value (e.g. []) can<br>
cause the interpreter to crash. It wasn't a problem until recently<br>
when I removed PyInterpreterState.modules and made sys.modules<br>
authoritative (see <a href="https://bugs.python.org/issue28411" rel="noreferrer" target="_blank">https://bugs.python.org/<wbr>issue28411</a>). The options<br>
there are:<br>
<br>
1. revert that change (which means assigning to sys.modules<br>
deceptively does nothing)<br>
2. raise an exception in all the places that expect sys.modules to be<br>
a mapping (far from where sys.modules was re-assigned)<br>
3. raise an exception if you try to set sys.modules to a non-mapping<br>
4. let a bogus sys.modules break the interpreter (basically, tell<br>
people "don't do that")<br>
<br>
My preference is #3 (obviously), but it sounds like you'd rather not.<br>
<span class=""><br>
> I think we have bigger fish to fry and this sounds like it could slow down startup.<br>
<br>
</span>It should have little impact on startup. The difference is the cost<br>
of importing the new sys module (which we could easily freeze to<br>
reduce the cost). That cost would apply only to programs that<br>
currently import sys. Everything in the stdlib would be updated to<br>
use _sys directly.<br>
<br>
If you think it isn't worth it then I'll let it go. I brought it up<br>
because I consider it a cheap, practical solution to the problem I ran<br>
into. Thanks!<br>
<span class="HOEnZb"><font color="#888888"><br>
-eric<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div>