handle errors from _PyObject_LookupSpecial when __get__ fails

This commit is contained in:
Benjamin Peterson 2009-05-25 02:40:21 +00:00
parent 176a56c69b
commit 87e5006d8c
5 changed files with 40 additions and 8 deletions

View file

@ -669,10 +669,12 @@ sys_getsizeof(PyObject *self, PyObject *args, PyObject *kwds)
else {
PyObject *method = _PyObject_LookupSpecial(o, "__sizeof__",
&str__sizeof__);
if (method == NULL)
PyErr_Format(PyExc_TypeError,
"Type %.100s doesn't define __sizeof__",
Py_TYPE(o)->tp_name);
if (method == NULL) {
if (!PyErr_Occurred())
PyErr_Format(PyExc_TypeError,
"Type %.100s doesn't define __sizeof__",
Py_TYPE(o)->tp_name);
}
else {
res = PyObject_CallFunctionObjArgs(method, NULL);
Py_DECREF(method);