Skip to content

Commit faf4957

Browse files
bpo-42528: Improve the docs of most Py*_Check{,Exact} API calls (GH-23602) (GH-24139)
I think that none of these API calls can fail, but only few of them are documented as such. Add the sentence "This function always succeeds" (which is the same already used e.g. by PyNumber_Check) to all of them. (cherry picked from commit 315fc52) Co-authored-by: Antonio Cuni <[email protected]> Co-authored-by: Antonio Cuni <[email protected]>
1 parent a3ca674 commit faf4957

26 files changed

+74
-52
lines changed

Doc/c-api/bool.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ are available, however.
1313

1414
.. c:function:: int PyBool_Check(PyObject *o)
1515
16-
Return true if *o* is of type :c:data:`PyBool_Type`.
16+
Return true if *o* is of type :c:data:`PyBool_Type`. This function always
17+
succeeds.
1718
1819
1920
.. c:var:: PyObject* Py_False

Doc/c-api/bytearray.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ Type check macros
2525
.. c:function:: int PyByteArray_Check(PyObject *o)
2626
2727
Return true if the object *o* is a bytearray object or an instance of a
28-
subtype of the bytearray type.
28+
subtype of the bytearray type. This function always succeeds.
2929
3030
3131
.. c:function:: int PyByteArray_CheckExact(PyObject *o)
3232
3333
Return true if the object *o* is a bytearray object, but not an instance of a
34-
subtype of the bytearray type.
34+
subtype of the bytearray type. This function always succeeds.
3535
3636
3737
Direct API functions

Doc/c-api/bytes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ called with a non-bytes parameter.
2525
.. c:function:: int PyBytes_Check(PyObject *o)
2626
2727
Return true if the object *o* is a bytes object or an instance of a subtype
28-
of the bytes type.
28+
of the bytes type. This function always succeeds.
2929
3030
3131
.. c:function:: int PyBytes_CheckExact(PyObject *o)
3232
3333
Return true if the object *o* is a bytes object, but not an instance of a
34-
subtype of the bytes type.
34+
subtype of the bytes type. This function always succeeds.
3535
3636
3737
.. c:function:: PyObject* PyBytes_FromString(const char *v)

Doc/c-api/capsule.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ Refer to :ref:`using-capsules` for more information on using these objects.
3434

3535
.. c:function:: int PyCapsule_CheckExact(PyObject *p)
3636
37-
Return true if its argument is a :c:type:`PyCapsule`.
37+
Return true if its argument is a :c:type:`PyCapsule`. This function always
38+
succeeds.
3839
3940
4041
.. c:function:: PyObject* PyCapsule_New(void *pointer, const char *name, PyCapsule_Destructor destructor)

Doc/c-api/cell.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Cell objects are not likely to be useful elsewhere.
2727

2828
.. c:function:: int PyCell_Check(ob)
2929
30-
Return true if *ob* is a cell object; *ob* must not be ``NULL``.
30+
Return true if *ob* is a cell object; *ob* must not be ``NULL``. This
31+
function always succeeds.
3132

3233

3334
.. c:function:: PyObject* PyCell_New(PyObject *ob)

Doc/c-api/code.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ bound into a function.
2727

2828
.. c:function:: int PyCode_Check(PyObject *co)
2929
30-
Return true if *co* is a :class:`code` object.
30+
Return true if *co* is a :class:`code` object. This function always succeeds.
3131
3232
.. c:function:: int PyCode_GetNumFree(PyCodeObject *co)
3333

Doc/c-api/complex.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ Complex Numbers as Python Objects
9494
.. c:function:: int PyComplex_Check(PyObject *p)
9595
9696
Return true if its argument is a :c:type:`PyComplexObject` or a subtype of
97-
:c:type:`PyComplexObject`.
97+
:c:type:`PyComplexObject`. This function always succeeds.
9898
9999
100100
.. c:function:: int PyComplex_CheckExact(PyObject *p)
101101
102102
Return true if its argument is a :c:type:`PyComplexObject`, but not a subtype of
103-
:c:type:`PyComplexObject`.
103+
:c:type:`PyComplexObject`. This function always succeeds.
104104
105105
106106
.. c:function:: PyObject* PyComplex_FromCComplex(Py_complex v)

Doc/c-api/coro.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ return.
2424
.. c:function:: int PyCoro_CheckExact(PyObject *ob)
2525
2626
Return true if *ob*'s type is :c:type:`PyCoro_Type`; *ob* must not be ``NULL``.
27+
This function always succeeds.
2728
2829
2930
.. c:function:: PyObject* PyCoro_New(PyFrameObject *frame, PyObject *name, PyObject *qualname)

Doc/c-api/datetime.rst

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,61 +28,66 @@ Type-check macros:
2828
.. c:function:: int PyDate_Check(PyObject *ob)
2929
3030
Return true if *ob* is of type :c:data:`PyDateTime_DateType` or a subtype of
31-
:c:data:`PyDateTime_DateType`. *ob* must not be ``NULL``.
31+
:c:data:`PyDateTime_DateType`. *ob* must not be ``NULL``. This function always
32+
succeeds.
3233
3334
3435
.. c:function:: int PyDate_CheckExact(PyObject *ob)
3536
3637
Return true if *ob* is of type :c:data:`PyDateTime_DateType`. *ob* must not be
37-
``NULL``.
38+
``NULL``. This function always succeeds.
3839
3940
4041
.. c:function:: int PyDateTime_Check(PyObject *ob)
4142
4243
Return true if *ob* is of type :c:data:`PyDateTime_DateTimeType` or a subtype of
43-
:c:data:`PyDateTime_DateTimeType`. *ob* must not be ``NULL``.
44+
:c:data:`PyDateTime_DateTimeType`. *ob* must not be ``NULL``. This function always
45+
succeeds.
4446
4547
4648
.. c:function:: int PyDateTime_CheckExact(PyObject *ob)
4749
4850
Return true if *ob* is of type :c:data:`PyDateTime_DateTimeType`. *ob* must not
49-
be ``NULL``.
51+
be ``NULL``. This function always succeeds.
5052
5153
5254
.. c:function:: int PyTime_Check(PyObject *ob)
5355
5456
Return true if *ob* is of type :c:data:`PyDateTime_TimeType` or a subtype of
55-
:c:data:`PyDateTime_TimeType`. *ob* must not be ``NULL``.
57+
:c:data:`PyDateTime_TimeType`. *ob* must not be ``NULL``. This function always
58+
succeeds.
5659
5760
5861
.. c:function:: int PyTime_CheckExact(PyObject *ob)
5962
6063
Return true if *ob* is of type :c:data:`PyDateTime_TimeType`. *ob* must not be
61-
``NULL``.
64+
``NULL``. This function always succeeds.
6265
6366
6467
.. c:function:: int PyDelta_Check(PyObject *ob)
6568
6669
Return true if *ob* is of type :c:data:`PyDateTime_DeltaType` or a subtype of
67-
:c:data:`PyDateTime_DeltaType`. *ob* must not be ``NULL``.
70+
:c:data:`PyDateTime_DeltaType`. *ob* must not be ``NULL``. This function always
71+
succeeds.
6872
6973
7074
.. c:function:: int PyDelta_CheckExact(PyObject *ob)
7175
7276
Return true if *ob* is of type :c:data:`PyDateTime_DeltaType`. *ob* must not be
73-
``NULL``.
77+
``NULL``. This function always succeeds.
7478
7579
7680
.. c:function:: int PyTZInfo_Check(PyObject *ob)
7781
7882
Return true if *ob* is of type :c:data:`PyDateTime_TZInfoType` or a subtype of
79-
:c:data:`PyDateTime_TZInfoType`. *ob* must not be ``NULL``.
83+
:c:data:`PyDateTime_TZInfoType`. *ob* must not be ``NULL``. This function always
84+
succeeds.
8085
8186
8287
.. c:function:: int PyTZInfo_CheckExact(PyObject *ob)
8388
8489
Return true if *ob* is of type :c:data:`PyDateTime_TZInfoType`. *ob* must not be
85-
``NULL``.
90+
``NULL``. This function always succeeds.
8691
8792
8893
Macros to create objects:

Doc/c-api/dict.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ Dictionary Objects
2222
.. c:function:: int PyDict_Check(PyObject *p)
2323
2424
Return true if *p* is a dict object or an instance of a subtype of the dict
25-
type.
25+
type. This function always succeeds.
2626
2727
2828
.. c:function:: int PyDict_CheckExact(PyObject *p)
2929
3030
Return true if *p* is a dict object, but not an instance of a subtype of
31-
the dict type.
31+
the dict type. This function always succeeds.
3232
3333
3434
.. c:function:: PyObject* PyDict_New()

0 commit comments

Comments
 (0)