On Wed, Oct 08, 2003 at 10:53:06PM -0400, Raymond Hettinger wrote: > if (res == -1 && PyErr_Occurred()) > return NULL; > ! return PyInt_FromLong((long)res); > } > > --- 3577,3583 ---- > if (res == -1 && PyErr_Occurred()) > return NULL; > ! ret = PyObject_IsTrue(PyInt_FromLong((long)res)) ? Py_True : > Py_False; > > > The line above leaks and does unnecessary work. I believe it should > read: > > ret = res ? Py_True : Py_False; PyInt_FromLong() returns PyObject, so you need to use PyObject_IsTrue() (the way I did) or hack the code not to use PyInt_FromLong(). I used PyInt_FromLong() because it was there before. Original code: res = (*func)(self, value); if (res == -1 && PyErr_Occurred()) return NULL; return PyInt_FromLong((long)res); } If you're sure it isn't needed, then of course we can use the easier way changing the snippet above into: res = (*func)(self, value); if (res == -1 && PyErr_Occurred()) return NULL; ret = res ? Py_True : Py_False; Py_INCREF(ret); return ret; } So, why was there PyInt_FromLong()? :> -- [ Wojtek Walczak - gminick (at) underground.org.pl ] [ <http://gminick.linuxsecurity.pl/> ] [ "...rozmaite zwroty, matowe od patyny dawnosci." ]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4