[Python-Dev] [compatibility-sig] making sure importlib.machinery.SourceLoader doesn't throw an exception if bytecode is not supported by a VM

Brett Cannon brett at python.org
Wed Jun 13 19:11:46 CEST 2012


On Wed, Jun 13, 2012 at 1:18 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> On Wed, Jun 13, 2012 at 11:10 AM, Brett Cannon <brett at python.org> wrote:
> >> > This does mean, though, that imp.cache_from_source() and
> >> > imp.source_from_cache() might need to be updated to raise a reasonable
> >> > exception when sys.implementation.cache_tag is set to None as I
> believe
> >> > right now it will raise a TypeError because None isn't a str. But what
> >> > to
> >> > raise instead? TypeError? EnvironmentError?
> >> NotImplementedError seems fine for me too if we don't end up using this
> >> flag.
> >
> > OK, that's 2 votes for that exception.
>
> + 1 from me as well, both for skipping any implicit reading or writing
> of the cache when cache_tag is None (IIRC, that's the use case we had
> in mind when we allowed that field to be None in the PEP 421
> discussion), and for *explicit* attempts to access the cache when the
> tag is None triggering NotImplementedError.
>
> That way people are free to use either LBYL (checking cache_tag) or
> EAFP (catching NotImplementedError).
>

I'm sold: http://bugs.python.org/issue15056 for tracking the change.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120613/005b4999/attachment.html>


More information about the Python-Dev mailing list