cpython/Doc/c-api/sentinel.rst
Jelle Zijlstra 29a92abb60
gh-148829: Implement PEP 661 (#148831)
Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2026-04-27 19:28:30 -07:00

35 lines
1.2 KiB
ReStructuredText

.. highlight:: c
.. _sentinelobjects:
Sentinel objects
----------------
.. c:var:: PyTypeObject PySentinel_Type
This instance of :c:type:`PyTypeObject` represents the Python
:class:`sentinel` type. This is the same object as :class:`sentinel`.
.. versionadded:: next
.. c:function:: int PySentinel_Check(PyObject *o)
Return true if *o* is a :class:`sentinel` object. The :class:`sentinel` type
does not allow subclasses, so this check is exact.
.. versionadded:: next
.. c:function:: PyObject* PySentinel_New(const char *name, const char *module_name)
Return a new :class:`sentinel` object with :attr:`~sentinel.__name__` set to
*name* and :attr:`~sentinel.__module__` set to *module_name*.
*name* must not be ``NULL``. If *module_name* is ``NULL``, :attr:`~sentinel.__module__`
is set to ``None``.
Return ``NULL`` with an exception set on failure.
For pickling to work, *module_name* must be the name of an importable
module, and the sentinel must be accessible from that module under a
path matching *name*. Pickle treats *name* as a global variable name
in *module_name* (see :meth:`object.__reduce__`).
.. versionadded:: next