diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-11-28 17:45:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-28 17:45:36 (GMT) |
commit | 24b51b1a4919e310d338629cc60371387f475a32 (patch) | |
tree | 3ef588788db8cd82c15559d5032ff73c8612556b /Lib/test/test_importlib/source | |
parent | f71a5922916abd6cc7bf7d99ed4715b6e96e5981 (diff) | |
download | cpython-24b51b1a4919e310d338629cc60371387f475a32.zip cpython-24b51b1a4919e310d338629cc60371387f475a32.tar.gz cpython-24b51b1a4919e310d338629cc60371387f475a32.tar.bz2 |
bpo-34022: Stop forcing of hash-based invalidation with SOURCE_DATE_EPOCH (GH-9607)
Unconditional forcing of ``CHECKED_HASH`` invalidation was introduced in
3.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()`` or ``compileall``. An environment variable
should *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 at
``SOURCE_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 work
with hash-based .pycs _at all_, though I left the fixes for
subsequent commits.
(cherry picked from commit a6b3ec5b6d4f6387820fccc570eea08b9615620d)
Co-authored-by: Elvis Pranskevichus <elvis@magic.io>
Diffstat (limited to 'Lib/test/test_importlib/source')
-rw-r--r-- | Lib/test/test_importlib/source/test_file_loader.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_importlib/source/test_file_loader.py b/Lib/test/test_importlib/source/test_file_loader.py index cc80f26..c916d7c 100644 --- a/Lib/test/test_importlib/source/test_file_loader.py +++ b/Lib/test/test_importlib/source/test_file_loader.py @@ -19,6 +19,9 @@ import warnings from test.support import make_legacy_pyc, unload +from test.test_py_compile import without_source_date_epoch +from test.test_py_compile import SourceDateEpochTestMeta + class SimpleTest(abc.LoaderTests): @@ -359,6 +362,17 @@ class SimpleTest(abc.LoaderTests): abc=importlib_abc, util=importlib_util) +class SourceDateEpochTestMeta(SourceDateEpochTestMeta, + type(Source_SimpleTest)): + pass + + +class SourceDateEpoch_SimpleTest(Source_SimpleTest, + metaclass=SourceDateEpochTestMeta, + source_date_epoch=True): + pass + + class BadBytecodeTest: def import_(self, file, module_name): @@ -617,6 +631,7 @@ class SourceLoaderBadBytecodeTest: # [bad timestamp] @util.writes_bytecode_files + @without_source_date_epoch def test_old_timestamp(self): # When the timestamp is older than the source, bytecode should be # regenerated. |