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

Skip to content

Commit db86561

Browse files
committed
has_finalizer(): simplified "if (complicated_bool) 1 else 0" to
"complicated_bool".
1 parent 49cc01e commit db86561

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

Modules/gcmodule.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,9 @@ has_finalizer(PyObject *op)
236236
if (delstr == NULL)
237237
Py_FatalError("PyGC: can't initialize __del__ string");
238238
}
239-
if ((PyInstance_Check(op) ||
240-
PyType_HasFeature(op->ob_type, Py_TPFLAGS_HEAPTYPE)) &&
241-
PyObject_HasAttr(op, delstr)) {
242-
return 1;
243-
}
244-
else {
245-
return 0;
246-
}
239+
return (PyInstance_Check(op) ||
240+
PyType_HasFeature(op->ob_type, Py_TPFLAGS_HEAPTYPE))
241+
&& PyObject_HasAttr(op, delstr);
247242
}
248243

249244
/* Move all objects with finalizers (instances with __del__) */

0 commit comments

Comments
 (0)