<br><br><div class="gmail_quote">On Fri, Jul 24, 2009 at 10:39, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Still works, at least in some old 3.1 I had lying around:<br>
</blockquote><div><br></div><div>Which reminds me, do we want to change the error message for ImportError in this case to say something like "import of {0} halted; None found in sys.modules"? Might be a tough exception to debug if you are not aware that some library shoved None into sys.modules.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
$ python3.1<br>
Python 3.1a0 (py3k:70152, Mar 3 2009, 16:55:42)<br>
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin<br>
Type "help", "copyright", "credits" or "license" for more information.<br>
>>> import sys<br>
>>> sys.modules['string'] = None<br>
>>> import string<br>
Traceback (most recent call last):<br>
File "<stdin>", line 1, in <module><br>
ImportError: No module named string<br>
>>><br>
$ python3.1<br>
Python 3.1a0 (py3k:70152, Mar 3 2009, 16:55:42)<br>
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin<br>
Type "help", "copyright", "credits" or "license" for more information.<br>
>>> import string<br>
>>><br>
$<br>
<br>
The experiment should be easily repeatable. :-)<br>
<font color="#888888"><br>
--Guido<br>
</font><div><div></div><div class="h5"><br>
On Thu, Jul 23, 2009 at 8:35 PM, Brett Cannon<<a href="mailto:brett@python.org">brett@python.org</a>> wrote:<br>
><br>
><br>
> On Thu, Jul 23, 2009 at 20:18, Guido van Rossum <<a href="mailto:guido@python.org">guido@python.org</a>> wrote:<br>
>><br>
>> So, I guess, we'll live with it for a while longer. Given that it<br>
>> managed to evade our attention for so long, I think that's fine.<br>
><br>
> Can someone double-check me that the semantics can even be triggered in 3.1?<br>
> I just tried and couldn't come up with anything. Heck, I quick search for a<br>
> Py_None comparison in 3.1's import.c turned up nothing useful (other than<br>
> mark_miss() is the function used to set None in sys.modules). We might have<br>
> actually already removed it or made it so that the semantics can't be<br>
> triggered.<br>
><br>
>><br>
>> I agree that there's no reason for a None result from loaders to be<br>
>> interpreted the same way, assuming that's not how it works ATM.<br>
>><br>
>> And we can live with import and importlib differing on this in 3.1<br>
>> (though you could call it a bug in importlib and fix it for 3.1.1 --<br>
>> not sure if you were planning on that).<br>
><br>
> I can if people can trigger the semantics somehow so I have a test to go by.<br>
> -Brett<br>
><br>
>><br>
>> --Guido<br>
>><br>
>> On Thu, Jul 23, 2009 at 7:50 PM, Brett Cannon<<a href="mailto:brett@python.org">brett@python.org</a>> wrote:<br>
>> ><br>
>> ><br>
>> > On Thu, Jul 23, 2009 at 19:48, Benjamin Peterson <<a href="mailto:benjamin@python.org">benjamin@python.org</a>><br>
>> > wrote:<br>
>> >><br>
>> >> 2009/7/23 Brett Cannon <<a href="mailto:brett@python.org">brett@python.org</a>>:<br>
>> >> ><br>
>> >> ><br>
>> >> > On Thu, Jul 23, 2009 at 19:38, Benjamin Peterson<br>
>> >> > <<a href="mailto:benjamin@python.org">benjamin@python.org</a>><br>
>> >> > wrote:<br>
>> >> >><br>
>> >> >> 2009/7/23 Brett Cannon <<a href="mailto:brett@python.org">brett@python.org</a>>:<br>
>> >> >> > None in Python 3.1 is really useless in terms of its semantics in<br>
>> >> >> > relative<br>
>> >> >> > imports; importlib doesn't support it and still passes as<br>
>> >> >> > __import__<br>
>> >> >> > (at<br>
>> >> >> > least last time I ran the test suite that way). I thought we had<br>
>> >> >> > agreed<br>
>> >> >> > a<br>
>> >> >> > while back that supporting None was not warranted in Python 3.0?<br>
>> >> >> > Otherwise I<br>
>> >> >> > will do whatever work is necessary for this to happen.<br>
>> >> >><br>
>> >> >> I think it's still nice for the rare cases where you need to trick a<br>
>> >> >> module into thinking another one doesn't exist.<br>
>> >> ><br>
>> >> > But None does not strictly mean "I don't exist". None is supposed to<br>
>> >> > trigger<br>
>> >> > an another import attempt for the module with a top-level name. It's<br>
>> >> > that<br>
>> >> > extra import trigger that has no real use in 3.0 and just complicates<br>
>> >> > import<br>
>> >> > semantics (IMO) needlessly. If you want a module to not exist then<br>
>> >> > you<br>
>> >> > either stick something else in (e.g. '42') or we remove the special<br>
>> >> > semantics for None (which I thought we had).<br>
>> >><br>
>> >><br>
>> >> I didn't realize None had other semantics attached to it. (Imagine<br>
>> >> that dealing with import!) +1 for making it simply indicate an<br>
>> >> ImportError.<br>
>> ><br>
>> > I'm +0 with having import raise ImportError if None is set in<br>
>> > sys.modules as<br>
>> > long as we don't suddenly expect loaders to trigger the same thing if<br>
>> > they<br>
>> > return None (actually, as of right now what loaders return count for<br>
>> > nothing, but just want to be clear).<br>
>> > -Brett<br>
>><br>
>><br>
>><br>
>> --<br>
>> --Guido van Rossum (home page: <a href="http://www.python.org/~guido/" target="_blank">http://www.python.org/~guido/</a>)<br>
><br>
><br>
<br>
<br>
<br>
</div></div>--<br>
<div><div></div><div class="h5">--Guido van Rossum (home page: <a href="http://www.python.org/~guido/" target="_blank">http://www.python.org/~guido/</a>)<br>
</div></div></blockquote></div><br>