Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3997cfd

Browse files
committed
Cleanup type_call() to ease debug
It was easy to miss the call to type->tp_init because it was done in a long conditional expression. Split the long expression in multiple lines to make the debug step by step easier.
1 parent 1e53bba commit 3997cfd

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Objects/typeobject.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,10 +750,12 @@ type_call(PyTypeObject *type, PyObject *args, PyObject *kwds)
750750
if (!PyType_IsSubtype(Py_TYPE(obj), type))
751751
return obj;
752752
type = Py_TYPE(obj);
753-
if (type->tp_init != NULL &&
754-
type->tp_init(obj, args, kwds) < 0) {
755-
Py_DECREF(obj);
756-
obj = NULL;
753+
if (type->tp_init != NULL) {
754+
int res = type->tp_init(obj, args, kwds);
755+
if (res < 0) {
756+
Py_DECREF(obj);
757+
obj = NULL;
758+
}
757759
}
758760
}
759761
return obj;

0 commit comments

Comments
 (0)