Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use the proper directives for getter and setter
  • Loading branch information
encukou committed Jan 24, 2024
commit 3405b9bc16999c581bdf390b4cc4a6e521b24fc2
12 changes: 6 additions & 6 deletions Doc/c-api/structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -669,18 +669,18 @@ Defining Getters and Setters

Optional function pointer, providing additional data for getter and setter.

The ``get`` function takes one :c:expr:`PyObject*` parameter (the
instance) and a function pointer (the associated ``closure``)::
.. c:type:: PyObject *(*getter)(PyObject *, void *)

typedef PyObject *(*getter)(PyObject *, void *);
The ``get`` function takes one :c:expr:`PyObject*` parameter (the
instance) and a function pointer (the associated ``closure``):

It should return a new reference on success or ``NULL`` with a set exception
on failure.

``set`` functions take two :c:expr:`PyObject*` parameters (the instance and
the value to be set) and a function pointer (the associated ``closure``)::
.. c:type:: int (*setter)(PyObject *, PyObject *, void *)

typedef int (*setter)(PyObject *, PyObject *, void *);
``set`` functions take two :c:expr:`PyObject*` parameters (the instance and
the value to be set) and a function pointer (the associated ``closure``):

In case the attribute should be deleted the second parameter is ``NULL``.
Should return ``0`` on success or ``-1`` with a set exception on failure.