Skip to content

Commit 56f020f

Browse files
committed
gh-140160: Rework PyObject_IsSubclass documentation…
1 parent 5a31024 commit 56f020f

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

Doc/c-api/object.rst

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -376,21 +376,17 @@ Object Protocol
376376
377377
.. c:function:: int PyObject_IsSubclass(PyObject *derived, PyObject *cls)
378378
379-
Return ``1`` if the class *derived* is identical to or derived from the class
380-
*cls*, otherwise return ``0``. In case of an error, return ``-1``.
379+
Return ``1`` if *derived* is a subclass of *cls*, ``0`` if not, or ``-1`` on
380+
error.
381381
382-
If *cls* is a tuple, the check will be done against every entry in *cls*.
383-
The result will be ``1`` when at least one of the checks returns ``1``,
384-
otherwise it will be ``0``.
385-
386-
If *cls* has a :meth:`~type.__subclasscheck__` method, it will be called to
387-
determine the subclass status as described in :pep:`3119`. Otherwise,
388-
*derived* is a subclass of *cls* if it is a direct or indirect subclass,
389-
i.e. contained in :attr:`cls.__mro__ <type.__mro__>`.
382+
If *cls* is a tuple, return ``1`` if *derived* is a subclass of any entry in
383+
*cls*.
390384
391-
Normally only class objects, i.e. instances of :class:`type` or a derived
392-
class, are considered classes. However, objects can override this by having
393-
a :attr:`~type.__bases__` attribute (which must be a tuple of base classes).
385+
The check respects :meth:`~type.__subclasscheck__` method if defined (see
386+
:pep:`3119`); otherwise, checks whether *derived* is in
387+
:attr:`cls.__mro__ <type.__mro__>`. Non-class objects with a
388+
:attr:`~type.__bases__` attribute (which must be a tuple of base classes)
389+
are also supported.
394390
395391
396392
.. c:function:: int PyObject_IsInstance(PyObject *inst, PyObject *cls)

0 commit comments

Comments
 (0)