[Python-checkins] cpython (2.7): Remove debug output, fix assert (hopefully) and exercise signedness issues a

antoine.pitrou python-checkins at python.org
Wed Jan 25 15:40:43 CET 2012


http://hg.python.org/cpython/rev/e8a525de2bac
changeset:   74610:e8a525de2bac
branch:      2.7
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Wed Jan 25 15:38:32 2012 +0100
summary:
  Remove debug output, fix assert (hopefully) and exercise signedness issues a bit more.

files:
  Lib/test/test_import.py |  2 +-
  Python/import.c         |  9 ++-------
  2 files changed, 3 insertions(+), 8 deletions(-)


diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -288,7 +288,7 @@
             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
--- a/Python/import.c
+++ b/Python/import.c
@@ -905,14 +905,9 @@
         (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);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list