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

Jeff Hardy jdhardy at gmail.com
Tue Jun 12 21:53:21 CEST 2012


On Tue, Jun 12, 2012 at 12:01 PM, Brett Cannon <brett at python.org> wrote:

On Tue, Jun 12, 2012 at 2:28 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote:

On Tue, Jun 12, 2012 at 10:48 AM, Brett Cannon <brett at python.org> wrote: > I should mention another option is to add sys.dontreadbytecode (I > think I > have discussed this with Frank at some point). Or check for "sys.implementation.cachetag is None"... Perfect! Will that work for Jython (Franke) and IronPython (Jeff)?

IronPython will probably never write pyc files, but it might read them at some point -- as I understand cache_tag, we'd set it to whatever version of CPython's pyc files we could read (that seems to violate the spirit of sys.implementation). The combination of that and sys.dont_write_bytecode should cover all of the states; I'll just lock down sys.dont_write_bytecode so that changes are completely ignored.

This does mean, though, that imp.cachefromsource() and imp.sourcefromcache() might need to be updated to raise a reasonable exception when sys.implementation.cachetag 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?



More information about the Python-Dev mailing list