Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 74612:2b62348a1c03
Port import fixes from 2.7.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Wed, 25 Jan 2012 18:06:07 +0100 |
| parents | cb13d8cff050 c79d0a7ac79d |
| children | e12b8d3a3d03 |
line wrap: on
line diff
--- a/Python/import.c Wed Jan 25 08:02:05 2012 +0200 +++ b/Python/import.c Wed Jan 25 18:06:07 2012 +0100 @@ -1343,9 +1343,9 @@ 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 @@ 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);
