[Python-Dev] avoiding accidental shadowing of top-level libraries by the main module

Michael Foord fuzzyman at voidspace.org.uk
Tue Jul 13 00:29:49 CEST 2010


On 12/07/2010 23:23, Nick Coghlan wrote:
> On Tue, Jul 13, 2010 at 8:06 AM, Michael Foord
> <fuzzyman at voidspace.org.uk>  wrote:
>    
>> An explicit error being raised instead would be just as good.
>>      
> Ah, refusing the temptation to guess.
>
> So the idea would be, when attempting to import __main__ under it's
> original name:
> 3.2 issue a DeprecationWarning
> 3.3 raise ImportError
>
>    
That's what I was suggesting.

> It still strikes me as wrong for the base import implementation, but
> PEP 302 may provide a mechanism for an interpreter shell to add its
> own "newbie protection" hooks (and that would have the virtue of being
> available much earlier and with a much lower chance of breaking
> anything).
>    

That would be a nice thing to have for earlier versions of Python. 
Personally I think the confusion the problem it causes would be nicer fixed.

All the best,

Michael

> Cheers,
> Nick.
>
>    


-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.




More information about the Python-Dev mailing list