summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-24 16:44:06 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-24 16:44:06 (GMT)
commit2be60afb7e0753c1bd5c297960cf8686a1ec7e1e (patch)
tree59dc4e7152c3bc9141b6dc000f8c10b1384a3750 /Python/import.c
parent7fa5a99b0693100077a556f05e3c6638b837389b (diff)
downloadcpython-2be60afb7e0753c1bd5c297960cf8686a1ec7e1e.zip
cpython-2be60afb7e0753c1bd5c297960cf8686a1ec7e1e.tar.gz
cpython-2be60afb7e0753c1bd5c297960cf8686a1ec7e1e.tar.bz2
Issue #11235: Fix OverflowError when trying to import a source file whose modification time doesn't fit in a 32-bit timestamp.
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/Python/import.c b/Python/import.c
index ee3f9b0..40b8d0a 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1304,14 +1304,11 @@ load_source_module(char *name, char *pathname, FILE *fp)
}
#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);