]> granicus.if.org Git - python/commitdiff
Cleanup type_call() to ease debug
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 16 Jul 2013 20:51:21 +0000 (22:51 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 16 Jul 2013 20:51:21 +0000 (22:51 +0200)
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.

Objects/typeobject.c

index 9b6902129975313f1adb5f2c63d7c6b6d43d1681..f311af8f25bb93ea8276344c5b6806fa6aa2d077 100644 (file)
@@ -750,10 +750,12 @@ type_call(PyTypeObject *type, PyObject *args, PyObject *kwds)
         if (!PyType_IsSubtype(Py_TYPE(obj), type))
             return obj;
         type = Py_TYPE(obj);
-        if (type->tp_init != NULL &&
-            type->tp_init(obj, args, kwds) < 0) {
-            Py_DECREF(obj);
-            obj = NULL;
+        if (type->tp_init != NULL) {
+            int res = type->tp_init(obj, args, kwds);
+            if (res < 0) {
+                Py_DECREF(obj);
+                obj = NULL;
+            }
         }
     }
     return obj;