Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 74596:a2f3d6986bfa 3.2
Issue #11235: Fix OverflowError when trying to import a source file whose modification time doesn't fit in a 32-bit timestamp.
| author | Antoine Pitrou <solipsis@pitrou.net> |
|---|---|
| date | Tue, 24 Jan 2012 17:44:06 +0100 |
| parents | f0cbceef47c3 |
| children | c79d0a7ac79d cb13d8cff050 |
line wrap: on
line diff
--- a/Python/import.c Tue Jan 24 09:07:06 2012 -0500 +++ b/Python/import.c Tue Jan 24 17:44:06 2012 +0100 @@ -1304,14 +1304,11 @@ } #if SIZEOF_TIME_T > 4 /* Python's .pyc timestamp handling presumes that the timestamp fits - in 4 bytes. This will be fine until sometime in the year 2038, - when a 4-byte signed time_t will overflow. + 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). */ - if (st.st_mtime >> 32) { - PyErr_SetString(PyExc_OverflowError, - "modification time overflows a 4 byte field"); - return NULL; - } + st.st_mtime &= 0xFFFFFFFF; #endif cpathname = make_compiled_pathname( pathname, buf, (size_t)MAXPATHLEN + 1, !Py_OptimizeFlag);
