summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-25 17:01:45 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-25 17:01:45 (GMT)
commit33d15f7c85c1700465bc89f896f2bafc58d2b2b5 (patch)
treea29254c1a65bebb15e0a7bc8d3c42794d25aa35a /Python/import.c
parentdd21f68963c2b17324b6018dbbf1b32b6e88f2c2 (diff)
downloadcpython-33d15f7c85c1700465bc89f896f2bafc58d2b2b5.zip
cpython-33d15f7c85c1700465bc89f896f2bafc58d2b2b5.tar.gz
cpython-33d15f7c85c1700465bc89f896f2bafc58d2b2b5.tar.bz2
Port import fixes from 2.7.
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/Python/import.c b/Python/import.c
index 40b8d0a..beda7f97 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1226,9 +1226,9 @@ write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat)
(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 @@ load_source_module(char *name, char *pathname, FILE *fp)
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 &&