mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
handle errors from _PyObject_LookupSpecial when __get__ fails
This commit is contained in:
parent
176a56c69b
commit
87e5006d8c
5 changed files with 40 additions and 8 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue