[Python-checkins] python/dist/src/Objects typeobject.c,2.195,2.196
Tim Peters
tim.one@comcast.net
2002年12月07日 16:46:59 -0500
- Previous message: [Python-checkins] python/dist/src/Objects typeobject.c,2.195,2.196
- Next message: [Python-checkins] python/nondist/sandbox/datetime obj_date.c,1.39,1.40 obj_datetime.c,1.37,1.38 obj_delta.c,1.24,1.25 obj_time.c,1.3,1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
> slot_nb_nonzero(): Another leak uncovered by the sandbox datetime
> tests. I found the logic too confusing to follow here, so rewrote more
> than was likely absolutely necessary.
Damn! I didn't mean to check in trim-trailing-whitespace changes too. This
is the only part of the patch that mattered:
***************
*** 3735,3740 ****
slot_nb_nonzero(PyObject *self)
{
! PyObject *func, *res, *args;
static PyObject *nonzero_str, *len_str;
func = lookup_maybe(self, "__nonzero__", &nonzero_str);
--- 3735,3741 ----
slot_nb_nonzero(PyObject *self)
{
! PyObject *func, *args;
static PyObject *nonzero_str, *len_str;
+ int result = -1;
func = lookup_maybe(self, "__nonzero__", &nonzero_str);
***************
*** 3743,3762 ****
return -1;
func = lookup_maybe(self, "__len__", &len_str);
! if (func == NULL) {
! if (PyErr_Occurred())
! return -1;
! else
! return 1;
! }
! }
! args = res = PyTuple_New(0);
if (args != NULL) {
! res = PyObject_Call(func, args, NULL);
Py_DECREF(args);
}
Py_DECREF(func);
! if (res == NULL)
! return -1;
! return PyObject_IsTrue(res);
}
--- 3744,3761 ----
return -1;
func = lookup_maybe(self, "__len__", &len_str);
! if (func == NULL)
! return PyErr_Occurred() ? -1 : 1;
! }
! args = PyTuple_New(0);
if (args != NULL) {
! PyObject *temp = PyObject_Call(func, args, NULL);
Py_DECREF(args);
+ if (temp != NULL) {
+ result = PyObject_IsTrue(temp);
+ Py_DECREF(temp);
+ }
}
Py_DECREF(func);
! return result;
}
- Previous message: [Python-checkins] python/dist/src/Objects typeobject.c,2.195,2.196
- Next message: [Python-checkins] python/nondist/sandbox/datetime obj_date.c,1.39,1.40 obj_datetime.c,1.37,1.38 obj_delta.c,1.24,1.25 obj_time.c,1.3,1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]