[Python-ideas] PEP: Distributing a Subset of the Standard Library
Wolfgang Maier
wolfgang.maier at biologie.uni-freiburg.de
Mon Nov 28 16:33:08 EST 2016
On 28.11.2016 22:26, Paul Moore wrote:
> 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...
>
How about addressing both concerns by triggering the search for
.missing.py only if an ImportError bubbles up uncaught (a bit similar to
StopIteration nowadays)?
Wolfgang
More information about the Python-ideas
mailing list