From 602117a6968ab74a473790d7486e14671208ce16 Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Thu, 28 Sep 2006 17:16:25 +0000 Subject: [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] --- Misc/NEWS | 3 +++ Modules/posixmodule.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Misc/NEWS b/Misc/NEWS index 036cf00..b066a0d 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 8906e2b..10fdf71 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) -- cgit v0.12