Allow tests to pass after 2038
without this change, the python-apache-libcloud tests failed in the year 2039 with fp.write(struct.pack("<ll", mtime, size)) E error: 'l' format requires -2147483648 <= number <= 2147483647
This commit is contained in:
parent
0f3d630634
commit
489c61a22d
|
@ -0,0 +1 @@
|
||||||
|
Fix handling of mtime to work after year 2038
|
|
@ -344,9 +344,9 @@ def _write_pyc(state, co, source_stat, pyc):
|
||||||
try:
|
try:
|
||||||
with atomicwrites.atomic_write(pyc, mode="wb", overwrite=True) as fp:
|
with atomicwrites.atomic_write(pyc, mode="wb", overwrite=True) as fp:
|
||||||
fp.write(imp.get_magic())
|
fp.write(imp.get_magic())
|
||||||
mtime = int(source_stat.mtime)
|
mtime = int(source_stat.mtime) & 0xFFFFFFFF
|
||||||
size = source_stat.size & 0xFFFFFFFF
|
size = source_stat.size & 0xFFFFFFFF
|
||||||
fp.write(struct.pack("<ll", mtime, size))
|
fp.write(struct.pack("<LL", mtime, size))
|
||||||
fp.write(marshal.dumps(co))
|
fp.write(marshal.dumps(co))
|
||||||
except EnvironmentError as e:
|
except EnvironmentError as e:
|
||||||
state.trace("error writing pyc file at %s: errno=%s" % (pyc, e.errno))
|
state.trace("error writing pyc file at %s: errno=%s" % (pyc, e.errno))
|
||||||
|
@ -441,7 +441,7 @@ def _read_pyc(source, pyc, trace=lambda x: None):
|
||||||
if (
|
if (
|
||||||
len(data) != 12
|
len(data) != 12
|
||||||
or data[:4] != imp.get_magic()
|
or data[:4] != imp.get_magic()
|
||||||
or struct.unpack("<ll", data[4:]) != (mtime, size)
|
or struct.unpack("<LL", data[4:]) != (mtime & 0xFFFFFFFF, size & 0xFFFFFFFF)
|
||||||
):
|
):
|
||||||
trace("_read_pyc(%s): invalid or out of date pyc" % source)
|
trace("_read_pyc(%s): invalid or out of date pyc" % source)
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue