From 0187af835bd1a609c8e118558e66795dfe525005 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Fri, 29 Dec 2023 14:05:54 +0200 Subject: [PATCH 1/5] Fix Sphinx warnings in c-api/structures.rst --- Doc/c-api/structures.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index 7d82f7839dfcd7..5a68a6bcfa5134 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -517,11 +517,11 @@ The following flags can be used with :c:member:`PyMemberDef.flags`: from ``PyObject``. Can only be used as part of :c:member:`Py_tp_members ` - :c:type:`slot ` when creating a class using negative + :c:type:`slot ` when creating a class using negative :c:member:`~PyType_Spec.basicsize`. It is mandatory in that case. - This flag is only used in :c:type:`PyTypeSlot`. + This flag is only used in :c:type:`PyType_Slot`. When setting :c:member:`~PyTypeObject.tp_members` during class creation, Python clears it and sets :c:member:`PyMemberDef.offset` to the offset from the ``PyObject`` struct. From 3405b9bc16999c581bdf390b4cc4a6e521b24fc2 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 24 Jan 2024 11:15:17 +0100 Subject: [PATCH 2/5] Use the proper directives for `getter` and `setter` --- Doc/c-api/structures.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index 5a68a6bcfa5134..ed79e2ebf2a0a8 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -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. From aefc58c3535987153e5cd500ead73dfbd8ac9ebb Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 24 Jan 2024 11:16:15 +0100 Subject: [PATCH 3/5] Use ``NULL`` rather than "omitted" for a C field --- Doc/c-api/structures.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index ed79e2ebf2a0a8..677689fae5bf4d 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -659,7 +659,8 @@ Defining Getters and Setters .. c:member:: setter set - Optional C function to set or delete the attribute, if omitted the attribute is readonly. + Optional C function to set or delete the attribute. + If ``NULL``, the attribute is readonly. .. c:member:: const char* doc From c8725cfd46283152c80807f197d993483c5d0a7d Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:02:21 +0200 Subject: [PATCH 4/5] All warnings fixedd in Doc/c-api/structures.rst --- Doc/tools/.nitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index ab6baf819de97a..ef7c23ae70a909 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -15,7 +15,6 @@ Doc/c-api/memoryview.rst Doc/c-api/module.rst Doc/c-api/object.rst Doc/c-api/stable.rst -Doc/c-api/structures.rst Doc/c-api/sys.rst Doc/c-api/type.rst Doc/c-api/typeobj.rst From fbba9a42f4872ddc673a9b3e58440e599a7e66d1 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Wed, 24 Jan 2024 13:02:59 +0200 Subject: [PATCH 5/5] Hyphenate read-only --- Doc/c-api/structures.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index 677689fae5bf4d..27bc45d25d17a7 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -660,7 +660,7 @@ Defining Getters and Setters .. c:member:: setter set Optional C function to set or delete the attribute. - If ``NULL``, the attribute is readonly. + If ``NULL``, the attribute is read-only. .. c:member:: const char* doc