diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-25 17:06:07 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-01-25 17:06:07 (GMT) |
commit | 581616624da7918e1050f3d02d0fb1e66e68c332 (patch) | |
tree | 18f9b7afa5e31154ee7f9859acc553139c09c8fd /Python | |
parent | 61baebd0e125ba281c2b1f40c210ce286e2e4f0d (diff) | |
parent | 33d15f7c85c1700465bc89f896f2bafc58d2b2b5 (diff) | |
download | cpython-581616624da7918e1050f3d02d0fb1e66e68c332.zip cpython-581616624da7918e1050f3d02d0fb1e66e68c332.tar.gz cpython-581616624da7918e1050f3d02d0fb1e66e68c332.tar.bz2 |
Port import fixes from 2.7.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/import.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Python/import.c b/Python/import.c index 487347c..d5b89d5 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1343,9 +1343,9 @@ write_compiled_module(PyCodeObject *co, PyObject *cpathname, PyMarshal_WriteLongToFile(0L, fp, Py_MARSHAL_VERSION); PyMarshal_WriteObjectToFile((PyObject *)co, fp, Py_MARSHAL_VERSION); fflush(fp); - /* Now write the true mtime and size */ + /* Now write the true mtime and size (as 32-bit fields) */ fseek(fp, 4L, 0); - assert(mtime < LONG_MAX); + assert(mtime <= 0xFFFFFFFF); PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION); PyMarshal_WriteLongToFile(size, fp, Py_MARSHAL_VERSION); if (fflush(fp) != 0 || ferror(fp)) { @@ -1476,14 +1476,14 @@ load_source_module(PyObject *name, PyObject *pathname, FILE *fp) pathname); goto error; } -#if SIZEOF_TIME_T > 4 - /* Python's .pyc timestamp handling presumes that the timestamp fits - in 4 bytes. Since the code only does an equality comparison, - ordering is not important and we can safely ignore the higher bits - (collisions are extremely unlikely). - */ - st.st_mtime &= 0xFFFFFFFF; -#endif + if (sizeof st.st_mtime > 4) { + /* Python's .pyc timestamp handling presumes that the timestamp fits + in 4 bytes. Since the code only does an equality comparison, + ordering is not important and we can safely ignore the higher bits + (collisions are extremely unlikely). + */ + st.st_mtime &= 0xFFFFFFFF; + } if (PyUnicode_READY(pathname) < 0) return NULL; cpathname = make_compiled_pathname(pathname, !Py_OptimizeFlag); |