From 489c61a22da0baa00d463f9780144befd68c2903 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Sun, 10 Mar 2019 05:03:24 +0100 Subject: [PATCH 1/2] Allow tests to pass after 2038 without this change, the python-apache-libcloud tests failed in the year 2039 with fp.write(struct.pack(" Date: Wed, 13 Mar 2019 18:52:30 -0300 Subject: [PATCH 2/2] Improve CHANGELOG and code comment --- changelog/4903.bugfix.rst | 2 +- src/_pytest/assertion/rewrite.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/changelog/4903.bugfix.rst b/changelog/4903.bugfix.rst index 1e80fecbf..116e1b0fd 100644 --- a/changelog/4903.bugfix.rst +++ b/changelog/4903.bugfix.rst @@ -1 +1 @@ -Fix handling of mtime to work after year 2038 +Use the correct modified time for years after 2038 in rewritten ``.pyc`` files. diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 3b53fd395..04ecbce5f 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -344,8 +344,10 @@ def _write_pyc(state, co, source_stat, pyc): try: with atomicwrites.atomic_write(pyc, mode="wb", overwrite=True) as fp: fp.write(imp.get_magic()) + # as of now, bytecode header expects 32-bit numbers for size and mtime (#4903) mtime = int(source_stat.mtime) & 0xFFFFFFFF size = source_stat.size & 0xFFFFFFFF + # "