Skip to content

gh-135755: Docs: C API: Document missing PyFunction_GET* macros #135762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions Doc/c-api/function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,21 @@ There are a few functions specific to Python functions.
Return the code object associated with the function object *op*.


.. c:function:: PyObject *PyFunction_GET_CODE(PyObject *op)

Similar to :c:func:`PyFunction_GetCode`, but without error checking.


.. c:function:: PyObject* PyFunction_GetGlobals(PyObject *op)

Return the globals dictionary associated with the function object *op*.


.. c:function:: PyObject *PyFunction_GET_GLOBALS(PyObject *op)

Similar to :c:func:`PyFunction_GetGlobals`, but without error checking.


.. c:function:: PyObject* PyFunction_GetModule(PyObject *op)

Return a :term:`borrowed reference` to the :attr:`~function.__module__`
Expand All @@ -72,12 +82,22 @@ There are a few functions specific to Python functions.
but can be set to any other object by Python code.


.. c:function:: PyObject *PyFunction_GET_MODULE(PyObject *op)

Similar to :c:func:`PyFunction_GetModule`, but without error checking.


.. c:function:: PyObject* PyFunction_GetDefaults(PyObject *op)

Return the argument default values of the function object *op*. This can be a
tuple of arguments or ``NULL``.


.. c:function:: PyObject *PyFunction_GET_DEFAULTS(PyObject *op)

Similar to :c:func:`PyFunction_GetDefaults`, but without error checking.


.. c:function:: int PyFunction_SetDefaults(PyObject *op, PyObject *defaults)

Set the argument default values for the function object *op*. *defaults* must be
Expand All @@ -95,12 +115,33 @@ There are a few functions specific to Python functions.

.. versionadded:: 3.12


.. c:function:: PyObject* PyFunction_GetKwDefaults(PyObject *op)

Return the keyword-only argument default values of the function object *op*. This can be a
dictionary of arguments or ``NULL``.

.. versionadded:: 3.0


.. c:function:: PyObject *PyFunction_GET_KW_DEFAULTS(PyObject *op)

Similar to :c:func:`PyFunction_GetKwDefaults`, but without error checking.

.. versionadded:: 3.0


.. c:function:: PyObject* PyFunction_GetClosure(PyObject *op)

Return the closure associated with the function object *op*. This can be ``NULL``
or a tuple of cell objects.


.. c:function:: PyObject *PyFunction_GET_CLOSURE(PyObject *op)

Similar to :c:func:`PyFunction_GetClosure`, but without error checking.


.. c:function:: int PyFunction_SetClosure(PyObject *op, PyObject *closure)

Set the closure associated with the function object *op*. *closure* must be
Expand All @@ -114,6 +155,15 @@ There are a few functions specific to Python functions.
Return the annotations of the function object *op*. This can be a
mutable dictionary or ``NULL``.

.. versionadded:: 3.0


.. c:function:: PyObject *PyFunction_GET_ANNOTATIONS(PyObject *op)

Similar to :c:func:`PyFunction_GetAnnotations`, but without error checking.

.. versionadded:: 3.0


.. c:function:: int PyFunction_SetAnnotations(PyObject *op, PyObject *annotations)

Expand All @@ -122,6 +172,8 @@ There are a few functions specific to Python functions.

Raises :exc:`SystemError` and returns ``-1`` on failure.

.. versionadded:: 3.0


.. c:function:: int PyFunction_AddWatcher(PyFunction_WatchCallback callback)

Expand Down
3 changes: 3 additions & 0 deletions Doc/data/refcounts.dat
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,9 @@ PyFunction_GetCode:PyObject*:op:0:
PyFunction_GetDefaults:PyObject*::0:
PyFunction_GetDefaults:PyObject*:op:0:

PyFunction_GetKwDefaults:PyObject*::0:
PyFunction_GetKwDefaults:PyObject*:op:0:

PyFunction_GetGlobals:PyObject*::0:
PyFunction_GetGlobals:PyObject*:op:0:

Expand Down
Loading