On Tue, Jun 12, 2012 at 12:01 PM, Brett Cannon <brett@python.org> wrote:
> On Tue, Jun 12, 2012 at 2:28 PM, Eric Snow <ericsnowcurrently@gmail.com>
> wrote:
>>
>> On Tue, Jun 12, 2012 at 10:48 AM, Brett Cannon <brett@python.org> wrote:
>> > I should mention another option is to add sys.dont_read_bytecode (I
>> > think I
>> > have discussed this with Frank at some point).
>>
>> Or check for "sys.implementation.cache_tag 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).

If you wanted to sneak around not writing your own bytecode but still reading it, then yes, you could do that. And yes, that does somewhat violate the concept of what sys.implementation.cache_tag was supposed to do. =)
">

(original) (raw)



On Tue, Jun 12, 2012 at 3:53 PM, Jeff Hardy <jdhardy@gmail.com> wrote:

On Tue, Jun 12, 2012 at 12:01 PM, Brett Cannon <brett@python.org> wrote:
> On Tue, Jun 12, 2012 at 2:28 PM, Eric Snow <ericsnowcurrently@gmail.com>
> wrote:
>>
>> On Tue, Jun 12, 2012 at 10:48 AM, Brett Cannon <brett@python.org> wrote:
>> > I should mention another option is to add sys.dont\_read\_bytecode (I
>> > think I
>> > have discussed this with Frank at some point).
>>
>> Or check for "sys.implementation.cache\_tag 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).

If you wanted to sneak around not writing your own bytecode but still reading it, then yes, you could do that. And yes, that does somewhat violate the concept of what sys.implementation.cache\_tag was supposed to do. =)
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.



Great!
>
> 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?

That's also a possibility. I also realized that importlib checks for None being returned by cache\_from\_source(), so that's another option (which ties into how the rest of the PEP 302 methods work).