]> granicus.if.org Git - python/commitdiff
Fix bug
authorMichael W. Hudson <mwh@python.net>
Tue, 5 Jul 2005 15:21:58 +0000 (15:21 +0000)
committerMichael W. Hudson <mwh@python.net>
Tue, 5 Jul 2005 15:21:58 +0000 (15:21 +0000)
1232517 ] OverflowError in time.utime() causes strange traceback

A needed error check was missing.

(Actually, this error check may only have become necessary in fairly
recent Python, not sure).

Backport candidate.

Misc/NEWS
Modules/posixmodule.c

index bcc696ae975212ec7b6a6d447809a5c7060b2c94..b3a56b0a3c42cd9a70f2ceb537e8c071ddd402c5 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.5 alpha 1?
 Core and builtins
 -----------------
 
+- SF bug #1232517: An overflow error was not detected properly when
+  attempting to convert a large float to an int in os.utime().
+
 - SF bug #1224347: hex longs now print with lowercase letters just
   like their int counterparts.
 
index e4a0200f046628be1908b8c5df19a81874610be0..e0c2b7f4f99671c98d7185e75aeabae6e4bd85ff 100644 (file)
@@ -1991,6 +1991,8 @@ extract_time(PyObject *t, long* sec, long* usec)
                        return -1;
                intval = PyInt_AsLong(intobj);
                Py_DECREF(intobj);
+               if (intval == -1 && PyErr_Occurred())
+                       return -1;
                *sec = intval;
                *usec = (long)((tval - intval) * 1e6); /* can't exceed 1000000 */
                if (*usec < 0)