Skip to content

Commit 897bc6f

Browse files
More minor fixes to C API docs (GH-31525)
* wording fixes in type.rst * grammar and punctuation in sys.rst * set: grammar fixes * structures: capitalization fix * grammar fixes for sequence * objects: point to Py_TYPE instead of direct object access * numbers: add more explicit Python equivalences * method: add missing period * memory: grammar fix * mapping: grammar fixes * long: grammar fix * iter: fix grammar for PyAIter_Check * init: grammar fix
1 parent 6066739 commit 897bc6f

File tree

13 files changed

+30
-29
lines changed

13 files changed

+30
-29
lines changed

Doc/c-api/init.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ is not possible due to its implementation being opaque at build time.
17921792
argument is `NULL`.
17931793
17941794
.. note::
1795-
A freed key becomes a dangling pointer, you should reset the key to
1795+
A freed key becomes a dangling pointer. You should reset the key to
17961796
`NULL`.
17971797
17981798

Doc/c-api/iter.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ There are two functions specifically for working with iterators.
1414
1515
.. c:function:: int PyAIter_Check(PyObject *o)
1616
17-
Returns non-zero if the object 'obj' provides :class:`AsyncIterator`
18-
protocols, and ``0`` otherwise. This function always succeeds.
17+
Return non-zero if the object *o* provides the :class:`AsyncIterator`
18+
protocol, and ``0`` otherwise. This function always succeeds.
1919
2020
.. versionadded:: 3.10
2121

Doc/c-api/long.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
4141
Return a new :c:type:`PyLongObject` object from *v*, or ``NULL`` on failure.
4242
4343
The current implementation keeps an array of integer objects for all integers
44-
between ``-5`` and ``256``, when you create an int in that range you actually
44+
between ``-5`` and ``256``. When you create an int in that range you actually
4545
just get back a reference to the existing object.
4646
4747

Doc/c-api/mapping.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` and
1111

1212
.. c:function:: int PyMapping_Check(PyObject *o)
1313
14-
Return ``1`` if the object provides mapping protocol or supports slicing,
14+
Return ``1`` if the object provides the mapping protocol or supports slicing,
1515
and ``0`` otherwise. Note that it returns ``1`` for Python classes with
16-
a :meth:`__getitem__` method since in general case it is impossible to
17-
determine what type of keys it supports. This function always succeeds.
16+
a :meth:`__getitem__` method, since in general it is impossible to
17+
determine what type of keys the class supports. This function always succeeds.
1818
1919
2020
.. c:function:: Py_ssize_t PyMapping_Size(PyObject *o)

Doc/c-api/memory.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ memory from the Python heap.
306306
307307
.. note::
308308
There is no guarantee that the memory returned by these allocators can be
309-
successfully casted to a Python object when intercepting the allocating
309+
successfully cast to a Python object when intercepting the allocating
310310
functions in this domain by the methods described in
311311
the :ref:`Customize Memory Allocators <customize-memory-allocators>` section.
312312

Doc/c-api/method.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ to bind a :c:data:`PyCFunction` to a class object. It replaces the former call
2727
2828
.. c:function:: PyObject* PyInstanceMethod_New(PyObject *func)
2929
30-
Return a new instance method object, with *func* being any callable object
30+
Return a new instance method object, with *func* being any callable object.
3131
*func* is the function that will be called when the instance method is
3232
called.
3333

Doc/c-api/number.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Number Protocol
4444
.. c:function:: PyObject* PyNumber_FloorDivide(PyObject *o1, PyObject *o2)
4545
4646
Return the floor of *o1* divided by *o2*, or ``NULL`` on failure. This is
47-
equivalent to the "classic" division of integers.
47+
the equivalent of the Python expression ``o1 // o2``.
4848
4949
5050
.. c:function:: PyObject* PyNumber_TrueDivide(PyObject *o1, PyObject *o2)
@@ -53,7 +53,7 @@ Number Protocol
5353
*o2*, or ``NULL`` on failure. The return value is "approximate" because binary
5454
floating point numbers are approximate; it is not possible to represent all real
5555
numbers in base two. This function can return a floating point value when
56-
passed two integers.
56+
passed two integers. This is the equivalent of the Python expression ``o1 / o2``.
5757
5858
5959
.. c:function:: PyObject* PyNumber_Remainder(PyObject *o1, PyObject *o2)
@@ -180,6 +180,7 @@ Number Protocol
180180
floating point numbers are approximate; it is not possible to represent all real
181181
numbers in base two. This function can return a floating point value when
182182
passed two integers. The operation is done *in-place* when *o1* supports it.
183+
This is the equivalent of the Python statement ``o1 /= o2``.
183184
184185
185186
.. c:function:: PyObject* PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2)
@@ -285,6 +286,6 @@ Number Protocol
285286
286287
.. c:function:: int PyIndex_Check(PyObject *o)
287288
288-
Returns ``1`` if *o* is an index integer (has the nb_index slot of the
289-
tp_as_number structure filled in), and ``0`` otherwise.
289+
Returns ``1`` if *o* is an index integer (has the ``nb_index`` slot of the
290+
``tp_as_number`` structure filled in), and ``0`` otherwise.
290291
This function always succeeds.

Doc/c-api/object.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Object Protocol
9393
return ``0`` on success. This is the equivalent of the Python statement
9494
``o.attr_name = v``.
9595
96-
If *v* is ``NULL``, the attribute is deleted, however this feature is
96+
If *v* is ``NULL``, the attribute is deleted, but this feature is
9797
deprecated in favour of using :c:func:`PyObject_DelAttrString`.
9898
9999
@@ -291,7 +291,7 @@ Object Protocol
291291
of object *o*. On failure, raises :exc:`SystemError` and returns ``NULL``. This
292292
is equivalent to the Python expression ``type(o)``. This function increments the
293293
reference count of the return value. There's really no reason to use this
294-
function instead of the common expression ``o->ob_type``, which returns a
294+
function instead of the :c:func:`Py_TYPE()` function, which returns a
295295
pointer of type :c:type:`PyTypeObject*`, except when the incremented reference
296296
count is needed.
297297

Doc/c-api/sequence.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Sequence Protocol
88

99
.. c:function:: int PySequence_Check(PyObject *o)
1010
11-
Return ``1`` if the object provides sequence protocol, and ``0`` otherwise.
11+
Return ``1`` if the object provides the sequence protocol, and ``0`` otherwise.
1212
Note that it returns ``1`` for Python classes with a :meth:`__getitem__`
13-
method unless they are :class:`dict` subclasses since in general case it
14-
is impossible to determine what the type of keys it supports. This
13+
method, unless they are :class:`dict` subclasses, since in general it
14+
is impossible to determine what type of keys the class supports. This
1515
function always succeeds.
1616
1717
@@ -69,7 +69,7 @@ Sequence Protocol
6969
is the equivalent of the Python statement ``o[i] = v``. This function *does
7070
not* steal a reference to *v*.
7171
72-
If *v* is ``NULL``, the element is deleted, however this feature is
72+
If *v* is ``NULL``, the element is deleted, but this feature is
7373
deprecated in favour of using :c:func:`PySequence_DelItem`.
7474
7575
@@ -147,7 +147,7 @@ Sequence Protocol
147147
148148
Returns the length of *o*, assuming that *o* was returned by
149149
:c:func:`PySequence_Fast` and that *o* is not ``NULL``. The size can also be
150-
gotten by calling :c:func:`PySequence_Size` on *o*, but
150+
retrieved by calling :c:func:`PySequence_Size` on *o*, but
151151
:c:func:`PySequence_Fast_GET_SIZE` is faster because it can assume *o* is a
152152
list or tuple.
153153

Doc/c-api/set.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Set Objects
1313
object: frozenset
1414

1515
This section details the public API for :class:`set` and :class:`frozenset`
16-
objects. Any functionality not listed below is best accessed using the either
16+
objects. Any functionality not listed below is best accessed using either
1717
the abstract object protocol (including :c:func:`PyObject_CallMethod`,
1818
:c:func:`PyObject_RichCompareBool`, :c:func:`PyObject_Hash`,
1919
:c:func:`PyObject_Repr`, :c:func:`PyObject_IsTrue`, :c:func:`PyObject_Print`, and
@@ -31,7 +31,7 @@ the abstract object protocol (including :c:func:`PyObject_CallMethod`,
3131
in that it is a fixed size for small sets (much like tuple storage) and will
3232
point to a separate, variable sized block of memory for medium and large sized
3333
sets (much like list storage). None of the fields of this structure should be
34-
considered public and are subject to change. All access should be done through
34+
considered public and all are subject to change. All access should be done through
3535
the documented API rather than by manipulating the values in the structure.
3636

3737

@@ -131,7 +131,7 @@ or :class:`frozenset` or instances of their subtypes.
131131
.. c:function:: int PySet_Add(PyObject *set, PyObject *key)
132132
133133
Add *key* to a :class:`set` instance. Also works with :class:`frozenset`
134-
instances (like :c:func:`PyTuple_SetItem` it can be used to fill-in the values
134+
instances (like :c:func:`PyTuple_SetItem` it can be used to fill in the values
135135
of brand new frozensets before they are exposed to other code). Return ``0`` on
136136
success or ``-1`` on failure. Raise a :exc:`TypeError` if the *key* is
137137
unhashable. Raise a :exc:`MemoryError` if there is no room to grow. Raise a

Doc/c-api/structures.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ Accessing attributes of extension types
504504
+=============+==================+===================================+
505505
| name | const char \* | attribute name |
506506
+-------------+------------------+-----------------------------------+
507-
| get | getter | C Function to get the attribute |
507+
| get | getter | C function to get the attribute |
508508
+-------------+------------------+-----------------------------------+
509509
| set | setter | optional C function to set or |
510510
| | | delete the attribute, if omitted |

Doc/c-api/sys.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Operating System Utilities
177177
178178
Return a pointer to a newly allocated byte string, use :c:func:`PyMem_Free`
179179
to free the memory. Return ``NULL`` on encoding error or memory allocation
180-
error
180+
error.
181181
182182
If error_pos is not ``NULL``, ``*error_pos`` is set to ``(size_t)-1`` on
183183
success, or set to the index of the invalid character on encoding error.
@@ -207,7 +207,7 @@ Operating System Utilities
207207
208208
.. versionchanged:: 3.8
209209
The function now uses the UTF-8 encoding on Windows if
210-
:c:data:`Py_LegacyWindowsFSEncodingFlag` is zero;
210+
:c:data:`Py_LegacyWindowsFSEncodingFlag` is zero.
211211
212212
213213
.. _systemfunctions:
@@ -356,7 +356,7 @@ accessible to C code. They all work with the current interpreter thread's
356356
.. c:function:: int PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
357357
358358
Append the callable *hook* to the list of active auditing hooks.
359-
Return zero for success
359+
Return zero on success
360360
and non-zero on failure. If the runtime has been initialized, also set an
361361
error on failure. Hooks added through this API are called for all
362362
interpreters created by the runtime.

Doc/c-api/type.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,12 @@ The following functions and structs are used to create
296296
297297
.. versionchanged:: 3.9
298298
299-
Slots in :c:type:`PyBufferProcs` in may be set in the unlimited API.
299+
Slots in :c:type:`PyBufferProcs` may be set in the unlimited API.
300300
301301
.. versionchanged:: 3.11
302302
:c:member:`~PyBufferProcs.bf_getbuffer` and
303303
:c:member:`~PyBufferProcs.bf_releasebuffer` are now available
304-
under limited API.
304+
under the limited API.
305305
306306
.. c:member:: void *PyType_Slot.pfunc
307307

0 commit comments

Comments
 (0)