handle errors from _PyObject_LookupSpecial when __get__ fails
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 1146746..6eb6b62 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -669,10 +669,12 @@
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);