[Python-ideas] PEP: Distributing a Subset of the Standard Library
Paul Moore
p.f.moore at gmail.com
Mon Nov 28 16:26:58 EST 2016
On 28 November 2016 at 21:11, Ethan Furman <ethan at stoneleaf.us> wrote:
> One "successful" use-case that would be impacted is the fallback import
> idiom:
>
> try:
> # this would do two full searches before getting the error
> import BlahBlah
> except ImportError:
> import blahblah
Under this proposal, the above idiom could potentially now fail. If
there's a BlahBlah.missing.py, then that will get executed rather than
an ImportError being raised, so the fallback wouldn't be executed.
This could actually be a serious issue for code that currently
protects against optional stdlib modules not being available like
this. There's no guarantee that I can see that a .missing.py file
would raise ImportError (even if we said that was the intended
behaviour, there's nothing to enforce it).
Could the proposal execute the .missing.py file and then raise
ImportError? I could imagine that having problems of its own,
though...
Paul
More information about the Python-ideas
mailing list