Commit 58161662 authored by Antoine Pitrou's avatar Antoine Pitrou

Port import fixes from 2.7.

parents 61baebd0 33d15f7c
...@@ -133,7 +133,7 @@ class SimpleTest(unittest.TestCase): ...@@ -133,7 +133,7 @@ class SimpleTest(unittest.TestCase):
with open(source, 'w') as f: with open(source, 'w') as f:
f.write("x = 5") f.write("x = 5")
try: try:
os.utime(source, (2 ** 33, 2 ** 33)) os.utime(source, (2 ** 33 - 5, 2 ** 33 - 5))
except OverflowError: except OverflowError:
self.skipTest("cannot set modification time to large integer") self.skipTest("cannot set modification time to large integer")
except OSError as e: except OSError as e:
......
...@@ -317,7 +317,7 @@ class ImportTests(unittest.TestCase): ...@@ -317,7 +317,7 @@ class ImportTests(unittest.TestCase):
with open(source, 'w') as f: with open(source, 'w') as f:
pass pass
try: try:
os.utime(source, (2 ** 33, 2 ** 33)) os.utime(source, (2 ** 33 - 5, 2 ** 33 - 5))
except OverflowError: except OverflowError:
self.skipTest("cannot set modification time to large integer") self.skipTest("cannot set modification time to large integer")
except OSError as e: except OSError as e:
......
...@@ -1343,9 +1343,9 @@ write_compiled_module(PyCodeObject *co, PyObject *cpathname, ...@@ -1343,9 +1343,9 @@ write_compiled_module(PyCodeObject *co, PyObject *cpathname,
PyMarshal_WriteLongToFile(0L, fp, Py_MARSHAL_VERSION); PyMarshal_WriteLongToFile(0L, fp, Py_MARSHAL_VERSION);
PyMarshal_WriteObjectToFile((PyObject *)co, fp, Py_MARSHAL_VERSION); PyMarshal_WriteObjectToFile((PyObject *)co, fp, Py_MARSHAL_VERSION);
fflush(fp); fflush(fp);
/* Now write the true mtime and size */ /* Now write the true mtime and size (as 32-bit fields) */
fseek(fp, 4L, 0); fseek(fp, 4L, 0);
assert(mtime < LONG_MAX); assert(mtime <= 0xFFFFFFFF);
PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION); PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION);
PyMarshal_WriteLongToFile(size, fp, Py_MARSHAL_VERSION); PyMarshal_WriteLongToFile(size, fp, Py_MARSHAL_VERSION);
if (fflush(fp) != 0 || ferror(fp)) { if (fflush(fp) != 0 || ferror(fp)) {
...@@ -1476,14 +1476,14 @@ load_source_module(PyObject *name, PyObject *pathname, FILE *fp) ...@@ -1476,14 +1476,14 @@ load_source_module(PyObject *name, PyObject *pathname, FILE *fp)
pathname); pathname);
goto error; goto error;
} }
#if SIZEOF_TIME_T > 4 if (sizeof st.st_mtime > 4) {
/* Python's .pyc timestamp handling presumes that the timestamp fits /* Python's .pyc timestamp handling presumes that the timestamp fits
in 4 bytes. Since the code only does an equality comparison, in 4 bytes. Since the code only does an equality comparison,
ordering is not important and we can safely ignore the higher bits ordering is not important and we can safely ignore the higher bits
(collisions are extremely unlikely). (collisions are extremely unlikely).
*/ */
st.st_mtime &= 0xFFFFFFFF; st.st_mtime &= 0xFFFFFFFF;
#endif }
if (PyUnicode_READY(pathname) < 0) if (PyUnicode_READY(pathname) < 0)
return NULL; return NULL;
cpathname = make_compiled_pathname(pathname, !Py_OptimizeFlag); cpathname = make_compiled_pathname(pathname, !Py_OptimizeFlag);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment