From 87e5006d8c5974597df9e3074b95227187d32be3 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Mon, 25 May 2009 02:40:21 +0000 Subject: handle errors from _PyObject_LookupSpecial when __get__ fails --- Python/sysmodule.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 1146746873..6eb6b62676 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -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); -- cgit v1.2.1