From: Andrew M. Kuchling Date: Thu, 28 Sep 2006 17:16:25 +0000 (+0000) Subject: [Backport rev. 39135 by mwh] X-Git-Tag: v2.4.4c1~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=602117a6968ab74a473790d7486e14671208ce16;p=thirdparty%2FPython%2Fcpython.git [Backport rev. 39135 by mwh] 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] --- diff --git a/Misc/NEWS b/Misc/NEWS index 036cf005a8a9..b066a0d2a18b 100644 --- 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. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 8906e2b478c8..10fdf719b224 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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)