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 + # "