From: Antoine Pitrou Date: Wed, 25 Jan 2012 14:38:32 +0000 (+0100) Subject: Remove debug output, fix assert (hopefully) and exercise signedness issues a bit... X-Git-Tag: v2.7.3rc1~126 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f25d75f25ae83285e3c3e95ca279e49ce5da691;p=python Remove debug output, fix assert (hopefully) and exercise signedness issues a bit more. --- diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index 412e6b8103..e426290df3 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -288,7 +288,7 @@ class ImportTests(unittest.TestCase): with open(source, 'w') as f: pass try: - os.utime(source, (2 ** 33, 2 ** 33)) + os.utime(source, (2 ** 33 - 5, 2 ** 33 - 5)) except OverflowError: self.skipTest("cannot set modification time to large integer") except OSError as e: diff --git a/Python/import.c b/Python/import.c index f9f3cdbbfb..2cac9b530b 100644 --- a/Python/import.c +++ b/Python/import.c @@ -905,14 +905,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); - if (mtime >= LONG_MAX) { - fprintf(stderr, "** sizes=(%ld, %ld), mtime=%I64d >= %ld\n", sizeof(time_t), sizeof(srcstat->st_mtime), mtime, LONG_MAX); - assert(0); - /* can't get here */ - } - assert(mtime < LONG_MAX); + assert(mtime <= 0xFFFFFFFF); PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION); fflush(fp); fclose(fp);