[Python-ideas] PEP: Distributing a Subset of the Standard Library

Steve Dower steve.dower at python.org
Mon Nov 28 17:33:31 EST 2016


On 28Nov2016 1419, Nathaniel Smith wrote:
> I'd suggest that we additional specify that if we find a
> foo.missing.py, then the code is executed but -- unlike a regular
> module load -- it's not automatically inserted into
> sys.modules["foo"]. That seems like it could only create confusion.
> And it doesn't restrict functionality, because if someone really wants
> to implement some clever shenanigans, they can always modify
> sys.modules["foo"] by hand.

In before Brett says "you can do this with an import hook", because, 
well, we can do this with an import hook :)

Given that, this wouldn't necessarily need to be an executable file. The 
finder could locate a "foo.missing" file and raise ModuleNotFoundError 
with the contents of the file as the message. No need to allow/require 
any Python code at all, and no risk of polluting sys.modules.

Cheers,
Steve


More information about the Python-ideas mailing list