From af9d4ab491d1c9870375211e5ed879f76c3ff91d Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Sun, 9 Nov 2025 11:03:32 -0500 Subject: [PATCH 1/3] Document PyClassMethod* and PyStaticMethod* --- Doc/c-api/descriptor.rst | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Doc/c-api/descriptor.rst b/Doc/c-api/descriptor.rst index ff0df575279d96..d7dfcf0f394427 100644 --- a/Doc/c-api/descriptor.rst +++ b/Doc/c-api/descriptor.rst @@ -38,3 +38,38 @@ found in the dictionary of type objects. .. c:function:: PyObject* PyWrapper_New(PyObject *, PyObject *) + + +Built-in descriptors +^^^^^^^^^^^^^^^^^^^^ + + +.. c:var:: PyTypeObject PyClassMethod_Type + + The type of class method objects. This is the same object as + :class:`classmethod` in the Python layer. + + +.. c:function:: PyObject *PyClassMethod_New(PyObject *callable) + + Create a new :class:`classmethod` object wrapping *callable*. + + On success, this function returns a :term:`strong reference` to a new class + method descriptor. On failure, this function returns ``NULL`` with an + exception set. + + +.. c:var:: PyTypeObject PyStaticMethod_Type + + The type of static method objects. This is the same object as + :class:`staticmethod` in the Python layer. + + +.. c:function:: PyObject *PyStaticMethod_New(PyObject *callable) + + Create a new :class:`staticmethod` object wrapping *callable*. + + On success, this function returns a :term:`strong reference` to a new static + method descriptor. On failure, this function returns ``NULL`` with an + exception set. + From e73bb24974374fa7247fb5711f7e7c6b1b77994d Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Sun, 9 Nov 2025 11:05:04 -0500 Subject: [PATCH 2/3] Remove extra newline. --- Doc/c-api/descriptor.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/c-api/descriptor.rst b/Doc/c-api/descriptor.rst index d7dfcf0f394427..f449996577cc0d 100644 --- a/Doc/c-api/descriptor.rst +++ b/Doc/c-api/descriptor.rst @@ -43,7 +43,6 @@ found in the dictionary of type objects. Built-in descriptors ^^^^^^^^^^^^^^^^^^^^ - .. c:var:: PyTypeObject PyClassMethod_Type The type of class method objects. This is the same object as From 6b1839fe476a1465c88850b5eba6c6df121b7adb Mon Sep 17 00:00:00 2001 From: Peter Bierma Date: Sun, 9 Nov 2025 12:51:25 -0500 Subject: [PATCH 3/3] Add clarification for the callable argument. --- Doc/c-api/descriptor.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/c-api/descriptor.rst b/Doc/c-api/descriptor.rst index f449996577cc0d..9a4093a7708a7c 100644 --- a/Doc/c-api/descriptor.rst +++ b/Doc/c-api/descriptor.rst @@ -52,6 +52,7 @@ Built-in descriptors .. c:function:: PyObject *PyClassMethod_New(PyObject *callable) Create a new :class:`classmethod` object wrapping *callable*. + *callable* must be a callable object and must not be ``NULL``. On success, this function returns a :term:`strong reference` to a new class method descriptor. On failure, this function returns ``NULL`` with an @@ -67,6 +68,7 @@ Built-in descriptors .. c:function:: PyObject *PyStaticMethod_New(PyObject *callable) Create a new :class:`staticmethod` object wrapping *callable*. + *callable* must be a callable object and must not be ``NULL``. On success, this function returns a :term:`strong reference` to a new static method descriptor. On failure, this function returns ``NULL`` with an