[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
Tue Jun 12 19:13:50 CEST 2012


On Tue, Jun 12, 2012 at 1:04 PM, fwierzbicki at gmail.com <
fwierzbicki at gmail.com> wrote:

> On Tue, Jun 12, 2012 at 9:38 AM, Alex Gaynor <alex.gaynor at gmail.com>
> wrote:
> > For PyPy: I'm not an expert in our import, but from looking at the source
> >
> > 1) imp.cache_from_source is unimplemented, it's an AttributeError.
> Jython does not (yet) have a cache_from_source.
>
> > 2) sys.dont_write_bytecode is always false, we don't respect that flag
> (we really
> >   should IMO, but it's not a high priority for me, or anyone else
> apparently)
> Jython does support sys.dont_write_bytecode, but doesn't support
> sys.dont_read_bytecode yet - do you happen to know when
> dont_read_bytecode was added?


It was never added since it doesn't currently exist; I said *add*
sys.dont_read_bytecode, not *use*. =)

Would the flag actually be beneficial? Have you had issues where people
assumed that Jython should be able to read bytecode since they just didn't
worry about a VM that can't read bytecode? I mean I'm open to suggestions
as ways to control bytecode reading to fail gracefully in case someone runs
Jython (or IronPython) in a directory where PyPy or CPython was run
previously and thus the bytecode exists from them. That's why I asked what
marshal.loads() does; if it returns None or raises some exception that can
be distinguished from a failure of badly formatted marshal data then I
could rely on that as another option.


> It should be pretty straightforward, and
> so I'll probably add it to our 2.7.
>

I would assume it would just be a flag for you. Importlib and other stdlib
code would be where all the work would be to start obeying the flag (if it
is added).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20120612/96b0ed60/attachment.html>


More information about the Python-Dev mailing list