From 33c3ac87eaef65c293d62952ccb31b680c7d69fa Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 9 Jul 2024 15:51:58 +0300 Subject: [PATCH 1/4] gh-121533: Improve `PyCell_[Get,Set]` docs: mention the exceptions --- Doc/c-api/cell.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/c-api/cell.rst b/Doc/c-api/cell.rst index f8cd0344fdd1c0..88186531916673 100644 --- a/Doc/c-api/cell.rst +++ b/Doc/c-api/cell.rst @@ -39,7 +39,8 @@ Cell objects are not likely to be useful elsewhere. .. c:function:: PyObject* PyCell_Get(PyObject *cell) - Return the contents of the cell *cell*. + Return the contents of the cell *cell*. If *cell* is not a cell object, + returns ``NULL`` with an exception set. .. c:function:: PyObject* PyCell_GET(PyObject *cell) @@ -52,8 +53,8 @@ Cell objects are not likely to be useful elsewhere. Set the contents of the cell object *cell* to *value*. This releases the reference to any current content of the cell. *value* may be ``NULL``. *cell* - must be non-``NULL``; if it is not a cell object, ``-1`` will be returned. On - success, ``0`` will be returned. + must be non-``NULL``; if it is not a cell object, ``-1`` will be returned + with an exception set. On success, ``0`` will be returned. .. c:function:: void PyCell_SET(PyObject *cell, PyObject *value) From 4c4061b6024c9d0ac590c060bee8adf4b4ffdf2e Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 9 Jul 2024 16:44:40 +0300 Subject: [PATCH 2/4] Address review --- Doc/c-api/cell.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/cell.rst b/Doc/c-api/cell.rst index 88186531916673..12e475ae02a33a 100644 --- a/Doc/c-api/cell.rst +++ b/Doc/c-api/cell.rst @@ -39,8 +39,8 @@ Cell objects are not likely to be useful elsewhere. .. c:function:: PyObject* PyCell_Get(PyObject *cell) - Return the contents of the cell *cell*. If *cell* is not a cell object, - returns ``NULL`` with an exception set. + Return the contents of the cell *cell*, which can be ``NULL``. + If *cell* is not a cell object, returns ``NULL`` with an exception set. .. c:function:: PyObject* PyCell_GET(PyObject *cell) From 4646d5bc20b0ea035846b9ca1b2fe4a71ec92cf3 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 9 Jul 2024 16:54:50 +0300 Subject: [PATCH 3/4] Update Doc/c-api/cell.rst Co-authored-by: Victor Stinner --- Doc/c-api/cell.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/cell.rst b/Doc/c-api/cell.rst index 12e475ae02a33a..9fd57e2c573ea7 100644 --- a/Doc/c-api/cell.rst +++ b/Doc/c-api/cell.rst @@ -53,8 +53,10 @@ Cell objects are not likely to be useful elsewhere. Set the contents of the cell object *cell* to *value*. This releases the reference to any current content of the cell. *value* may be ``NULL``. *cell* - must be non-``NULL``; if it is not a cell object, ``-1`` will be returned - with an exception set. On success, ``0`` will be returned. + must be non-``NULL``. + + On success, return ``0``. + If *cell* is not a cell object, set an exception and return ``-1``. .. c:function:: void PyCell_SET(PyObject *cell, PyObject *value) From f0af93f778cbd97eb5199ae236f6210ccc0a5586 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Tue, 9 Jul 2024 18:10:11 +0300 Subject: [PATCH 4/4] Update cell.rst --- Doc/c-api/cell.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/cell.rst b/Doc/c-api/cell.rst index 9fd57e2c573ea7..61eb994c370946 100644 --- a/Doc/c-api/cell.rst +++ b/Doc/c-api/cell.rst @@ -54,7 +54,7 @@ Cell objects are not likely to be useful elsewhere. Set the contents of the cell object *cell* to *value*. This releases the reference to any current content of the cell. *value* may be ``NULL``. *cell* must be non-``NULL``. - + On success, return ``0``. If *cell* is not a cell object, set an exception and return ``-1``.