You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Have imp.cache_from_source() raise NotImplementedError when cache tag not available #59261
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2012-07-09.17:59:21.100>created_at=<Date2012-06-13.17:10:51.716>labels= ['easy', 'library', 'release-blocker']
title='Have imp.cache_from_source() raise NotImplementedError when cache tag not available'updated_at=<Date2012-07-09.17:59:21.099>user='https://github.com/brettcannon'
It seems to me there is overlap between sys.implementation.cache_tag and sys.dont_write_bytecode. I was expecting sys.impl.cache_tag to be purely informational, and not actually controlling some behavior. “If cache_tag is set to None, it indicates that module caching should be disabled”: isn’t that the job of sys.dont_write_bytecode?
(The difference that I see is that sys.impl.cache_tag is defined by the VM and dont_write_bytecode by each interpreter invocation; I was expecting VMs that never want to write bytecode to just always set dont_write_bytecode to False, i.e. make -B redundant.)
So sys.dont_write_bytecode is there to prevent bytecode writing but not loading. This is an issue for some systems (e.g. clusters) where there are so many processes running Python that they start to trample each others bytecode files and it leads to malformed data. If you set sys.implementation.cache_tag to None you stop all bytecode usage (reading and writing), and thus is "disabled" entirely, not just for writing.
PranavRavichandran commented on Jun 20, 2012
PranavRavichandranmannequin
Mannequin
More actions
First-time contributor here, so just to make sure, let me just clarify this - the trunk builds fine, but one of the tests, test_urllib2_localnet, fails, I'm not sure why. Also, the patch is kind of messed up because of changes to Python/importlib.h. I looked this up on google, but wasn't able to find much help. Awaiting feedback :)
So sys.dont_write_bytecode is there to prevent bytecode writing but not loading.
Ah right. Providing a way to avoid reading them sounds good.
If you set sys.implementation.cache_tag to None you stop all bytecode usage (reading and writing)
This I feel uncomfortable with. First, I would separate writing and reading; second, I think of sys.implementation as a read-only information holder, and would think it immutable (note that I haven’t read the latest version of the PEP); just like sys.flags.dont_write_bytecode does not change but sys.dont_write_bytecode can change. So even though I think sys has a lot of attributes, the cleanest thing here would be a new sys.dont_read_bytecode attribute (as was proposed in the thread), maybe also with a new command-line option (or using -BB) and environment variable.
Brett meant the implementation would set it. You'd still expect it to not change values during the execution of the interpreter. I suppose anyone could change that value, but I'd see that more as a consenting adults situation.
Thanks for the patch, Pranav. I'm probably going to be too busy for a couple of weeks, so I won't look at this immediately, but I wanted to let you know I will eventually get to it.
Activity
brettcannon commentedon Jun 13, 2012
Both imp.cache_from_source() and source_from_cache() should throw NotImplementedError when sys.implementation.cache_tag is None. See the thread starting at http://mail.python.org/pipermail/python-dev/2012-June/120145.html for discussion of this decision.
merwok commentedon Jun 13, 2012
It seems to me there is overlap between sys.implementation.cache_tag and sys.dont_write_bytecode. I was expecting sys.impl.cache_tag to be purely informational, and not actually controlling some behavior. “If cache_tag is set to None, it indicates that module caching should be disabled”: isn’t that the job of sys.dont_write_bytecode?
(The difference that I see is that sys.impl.cache_tag is defined by the VM and dont_write_bytecode by each interpreter invocation; I was expecting VMs that never want to write bytecode to just always set dont_write_bytecode to False, i.e. make -B redundant.)
brettcannon commentedon Jun 14, 2012
So sys.dont_write_bytecode is there to prevent bytecode writing but not loading. This is an issue for some systems (e.g. clusters) where there are so many processes running Python that they start to trample each others bytecode files and it leads to malformed data. If you set sys.implementation.cache_tag to None you stop all bytecode usage (reading and writing), and thus is "disabled" entirely, not just for writing.
PranavRavichandran commentedon Jun 20, 2012
First-time contributor here, so just to make sure, let me just clarify this - the trunk builds fine, but one of the tests, test_urllib2_localnet, fails, I'm not sure why. Also, the patch is kind of messed up because of changes to Python/importlib.h. I looked this up on google, but wasn't able to find much help. Awaiting feedback :)
merwok commentedon Jun 24, 2012
ericsnowcurrently commentedon Jun 24, 2012
Brett meant the implementation would set it. You'd still expect it to not change values during the execution of the interpreter. I suppose anyone could change that value, but I'd see that more as a consenting adults situation.
brettcannon commentedon Jun 24, 2012
Thanks for the patch, Pranav. I'm probably going to be too busy for a couple of weeks, so I won't look at this immediately, but I wanted to let you know I will eventually get to it.
birkenfeld commentedon Jun 26, 2012
Moving back to blocker for beta2.
python-dev commentedon Jul 9, 2012
New changeset e86330669bb5 by Brett Cannon in branch 'default':
Issue bpo-15056: imp.cache_from_source() and source_from_cache() raise
http://hg.python.org/cpython/rev/e86330669bb5
brettcannon commentedon Jul 9, 2012
I released Pranav's patch and fleshed it out with docs, tests, and changes to importlib's use of cache_from_source().