Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 74611:c79d0a7ac79d 3.2
Port import fixes from 2.7.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Wed, 25 Jan 2012 18:01:45 +0100 |
| parents | a2f3d6986bfa |
| children | 963a0fba98e0 2b62348a1c03 |
line wrap: on
line diff
--- a/Python/import.c Wed Jan 25 03:00:57 2012 +0100 +++ b/Python/import.c Wed Jan 25 18:01:45 2012 +0100 @@ -1226,9 +1226,9 @@ (void) unlink(cpathname); return; } - /* Now write the true mtime */ + /* Now write the true mtime (as a 32-bit field) */ fseek(fp, 4L, 0); - assert(mtime < LONG_MAX); + assert(mtime <= 0xFFFFFFFF); PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION); fflush(fp); fclose(fp); @@ -1302,14 +1302,14 @@ pathname); return NULL; } -#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; + } cpathname = make_compiled_pathname( pathname, buf, (size_t)MAXPATHLEN + 1, !Py_OptimizeFlag); if (cpathname != NULL &&
