[3.7] bpo-34022: Stop forcing of hash-based invalidation with SOURCE_DATE_EPOCH (GH-9607) #10775
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Unconditional forcing of
CHECKED_HASH
invalidation was introduced in3.7.0 in bpo-29708. The change is bad, as it unconditionally overrides
invalidation_mode, even if it was passed as an explicit argument to
py_compile.compile()
orcompileall
. An environment variableshould never override an explicit argument to a library function.
That change leads to multiple test failures if the
SOURCE_DATE_EPOCH
environment variable is set.
This changes
py_compile.compile()
to only look atSOURCE_DATE_EPOCH
if no explicit invalidation_mode was specified.I also made various relevant tests run with explicit control over the
value of
SOURCE_DATE_EPOCH
.While looking at this, I noticed that
zipimport
does not workwith hash-based .pycs at all, though I left the fixes for
subsequent commits.
(cherry picked from commit a6b3ec5)
Co-authored-by: Elvis Pranskevichus elvis@magic.io
https://bugs.python.org/issue34022