[Python-bugs-list] [ python-Bugs-690253 ] Strange control flow in PyInt_AsLong
SourceForge.net
noreply@sourceforge.net
Thu, 20 Feb 2003 13:16:26 -0800
Bugs item #690253, was opened at 2003-02-20 21:14
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=690253&group_id=5470
Category: None
Group: None
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Thomas Heller (theller)
Assigned to: Thomas Heller (theller)
Summary: Strange control flow in PyInt_AsLong
Initial Comment:
When nb_int is called inside the PyInt_AsLong function,
and this returns a long, the value is first retrieved
with PyLong_AsLong, but afterwards overwritten by a
call to PyInt_AS_LONG.
Patch:
*** intobject.c 12 Feb 2003 20:43:33 -0000 2.102
--- intobject.c 20 Feb 2003 20:05:32 -0000
***************
*** 162,171 ****
if (PyLong_Check(io)) {
/* got a long? => retry int conversion */
val = PyLong_AsLong((PyObject *)io);
! if (PyErr_Occurred()) {
! Py_DECREF(io);
return -1;
! }
}
else
{
--- 162,171 ----
if (PyLong_Check(io)) {
/* got a long? => retry int conversion */
val = PyLong_AsLong((PyObject *)io);
! Py_DECREF(io);
! if (PyErr_Occurred())
return -1;
! return val;
}
else
{
----------------------------------------------------------------------
>Comment By: Thomas Heller (theller)
Date: 2003-02-20 22:16
Message:
Logged In: YES
user_id=11105
Dunno either, I found it when reading the code, not when
hunting for a bug.
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2003-02-20 22:13
Message:
Logged In: YES
user_id=31435
Dunno --didn't pay enough attention. Was it an actual bug, or
just a lack of grace?
----------------------------------------------------------------------
Comment By: Thomas Heller (theller)
Date: 2003-02-20 21:49
Message:
Logged In: YES
user_id=11105
Checked in, with your improvement. I don't have a 2.2-maint
branch handy at the moment, is this also an issue there?
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2003-02-20 21:34
Message:
Logged In: YES
user_id=31435
Sounds good to me. As long as you're at it <wink>, don't call
PyErr_Occurred() unless val is -1 either.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=690253&group_id=5470