Skip to content

Commit 44cb510

Browse files
committed
Improve CHANGELOG and code comment
1 parent 489c61a commit 44cb510

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

changelog/4903.bugfix.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Fix handling of mtime to work after year 2038
1+
Use the correct modified time for years after 2038 in rewritten ``.pyc`` files.

src/_pytest/assertion/rewrite.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,10 @@ def _write_pyc(state, co, source_stat, pyc):
344344
try:
345345
with atomicwrites.atomic_write(pyc, mode="wb", overwrite=True) as fp:
346346
fp.write(imp.get_magic())
347+
# as of now, bytecode header expects 32-bit numbers for size and mtime (#4903)
347348
mtime = int(source_stat.mtime) & 0xFFFFFFFF
348349
size = source_stat.size & 0xFFFFFFFF
350+
# "<LL" stands for 2 unsigned longs, little-ending
349351
fp.write(struct.pack("<LL", mtime, size))
350352
fp.write(marshal.dumps(co))
351353
except EnvironmentError as e:

0 commit comments

Comments
 (0)