]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Backport rev. 39135 by mwh]
authorAndrew M. Kuchling <amk@amk.ca>
Thu, 28 Sep 2006 17:16:25 +0000 (17:16 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Thu, 28 Sep 2006 17:16:25 +0000 (17:16 +0000)
Fix bug

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.

[A few lines below the code in 2.4 touched by the patch, there's already
 a similar check of (intval == -1 && PyErr_Occurred()), so I think
 this function can already report such errors, and therefore the fix
 still applies.  Perhaps Michael can clarify what he was referring to. --amk]

Misc/NEWS
Modules/posixmodule.c

index 036cf005a8a97663ec2a31e3d2511bac1a4ab7a6..b066a0d2a18bfd9898abc8cb08a9bb6509a8ac5f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -27,6 +27,9 @@ Core and builtins
 
 - Bug #1524310: Properly report errors from FindNextFile in os.listdir.
 
+- Bug #1232517: An overflow error was not detected properly when
+  attempting to convert a large float to an int in os.utime().
+
 - Bug #927248: Recursive method-wrapper objects can now safely
   be released.
 
index 8906e2b478c8dc4780409d6ca07bd8444f5023a1..10fdf719b2244cee50ee517c669479c1e0de9eac 100644 (file)
@@ -2004,6 +2004,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)