Skip to content

Commit 4245764

Browse files
[3.10] gh-93738: Documentation C syntax (:c:type:PyObject -> :c:expr:PyObject) (GH-97776) (#97888)
:c:type:`PyObject` -> :c:expr:`PyObject` (cherry picked from commit 0bf6a61) Co-authored-by: Adam Turner <[email protected]>
1 parent d108eeb commit 4245764

File tree

10 files changed

+30
-30
lines changed

10 files changed

+30
-30
lines changed

Doc/c-api/arg.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ which disallows mutable objects such as :class:`bytearray`.
129129
``S`` (:class:`bytes`) [PyBytesObject \*]
130130
Requires that the Python object is a :class:`bytes` object, without
131131
attempting any conversion. Raises :exc:`TypeError` if the object is not
132-
a bytes object. The C variable may also be declared as :c:type:`PyObject*`.
132+
a bytes object. The C variable may also be declared as :c:expr:`PyObject*`.
133133

134134
``Y`` (:class:`bytearray`) [PyByteArrayObject \*]
135135
Requires that the Python object is a :class:`bytearray` object, without
136136
attempting any conversion. Raises :exc:`TypeError` if the object is not
137-
a :class:`bytearray` object. The C variable may also be declared as :c:type:`PyObject*`.
137+
a :class:`bytearray` object. The C variable may also be declared as :c:expr:`PyObject*`.
138138

139139
``u`` (:class:`str`) [const Py_UNICODE \*]
140140
Convert a Python Unicode object to a C pointer to a NUL-terminated buffer of
@@ -181,7 +181,7 @@ which disallows mutable objects such as :class:`bytearray`.
181181
``U`` (:class:`str`) [PyObject \*]
182182
Requires that the Python object is a Unicode object, without attempting
183183
any conversion. Raises :exc:`TypeError` if the object is not a Unicode
184-
object. The C variable may also be declared as :c:type:`PyObject*`.
184+
object. The C variable may also be declared as :c:expr:`PyObject*`.
185185

186186
``w*`` (read-write :term:`bytes-like object`) [Py_buffer]
187187
This format accepts any object which implements the read-write buffer
@@ -320,7 +320,7 @@ Other objects
320320
``O!`` (object) [*typeobject*, PyObject \*]
321321
Store a Python object in a C object pointer. This is similar to ``O``, but
322322
takes two C arguments: the first is the address of a Python type object, the
323-
second is the address of the C variable (of type :c:type:`PyObject*`) into which
323+
second is the address of the C variable (of type :c:expr:`PyObject*`) into which
324324
the object pointer is stored. If the Python object does not have the required
325325
type, :exc:`TypeError` is raised.
326326

@@ -481,7 +481,7 @@ API Functions
481481
*args*; it must actually be a tuple. The length of the tuple must be at least
482482
*min* and no more than *max*; *min* and *max* may be equal. Additional
483483
arguments must be passed to the function, each of which should be a pointer to a
484-
:c:type:`PyObject*` variable; these will be filled in with the values from
484+
:c:expr:`PyObject*` variable; these will be filled in with the values from
485485
*args*; they will contain :term:`borrowed references <borrowed reference>`.
486486
The variables which correspond
487487
to optional parameters not given by *args* will not be filled in; these should

Doc/c-api/call.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ please see individual documentation for details.
275275
276276
This is the equivalent of the Python expression: ``callable(*args)``.
277277
278-
Note that if you only pass :c:type:`PyObject *` args,
278+
Note that if you only pass :c:expr:`PyObject *` args,
279279
:c:func:`PyObject_CallFunctionObjArgs` is a faster alternative.
280280
281281
.. versionchanged:: 3.4
@@ -296,7 +296,7 @@ please see individual documentation for details.
296296
This is the equivalent of the Python expression:
297297
``obj.name(arg1, arg2, ...)``.
298298
299-
Note that if you only pass :c:type:`PyObject *` args,
299+
Note that if you only pass :c:expr:`PyObject *` args,
300300
:c:func:`PyObject_CallMethodObjArgs` is a faster alternative.
301301
302302
.. versionchanged:: 3.4
@@ -306,7 +306,7 @@ please see individual documentation for details.
306306
.. c:function:: PyObject* PyObject_CallFunctionObjArgs(PyObject *callable, ...)
307307
308308
Call a callable Python object *callable*, with a variable number of
309-
:c:type:`PyObject *` arguments. The arguments are provided as a variable number
309+
:c:expr:`PyObject *` arguments. The arguments are provided as a variable number
310310
of parameters followed by *NULL*.
311311
312312
Return the result of the call on success, or raise an exception and return
@@ -320,7 +320,7 @@ please see individual documentation for details.
320320
321321
Call a method of the Python object *obj*, where the name of the method is given as a
322322
Python string object in *name*. It is called with a variable number of
323-
:c:type:`PyObject *` arguments. The arguments are provided as a variable number
323+
:c:expr:`PyObject *` arguments. The arguments are provided as a variable number
324324
of parameters followed by *NULL*.
325325
326326
Return the result of the call on success, or raise an exception and return

Doc/c-api/dict.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Dictionary Objects
118118
.. c:function:: PyObject* PyDict_GetItemString(PyObject *p, const char *key)
119119
120120
This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as a
121-
:c:type:`const char*`, rather than a :c:type:`PyObject*`.
121+
:c:type:`const char*`, rather than a :c:expr:`PyObject*`.
122122
123123
Note that exceptions which occur while calling :meth:`__hash__` and
124124
:meth:`__eq__` methods and creating a temporary string object
@@ -167,7 +167,7 @@ Dictionary Objects
167167
prior to the first call to this function to start the iteration; the
168168
function returns true for each pair in the dictionary, and false once all
169169
pairs have been reported. The parameters *pkey* and *pvalue* should either
170-
point to :c:type:`PyObject*` variables that will be filled in with each key
170+
point to :c:expr:`PyObject*` variables that will be filled in with each key
171171
and value, respectively, or may be ``NULL``. Any references returned through
172172
them are borrowed. *ppos* should not be altered during iteration. Its
173173
value represents offsets within the internal dictionary structure, and

Doc/c-api/exceptions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ Standard Exceptions
828828
829829
All standard Python exceptions are available as global variables whose names are
830830
``PyExc_`` followed by the Python exception name. These have the type
831-
:c:type:`PyObject*`; they are all class objects. For completeness, here are all
831+
:c:expr:`PyObject*`; they are all class objects. For completeness, here are all
832832
the variables:
833833
834834
.. index::
@@ -1048,7 +1048,7 @@ Standard Warning Categories
10481048
10491049
All standard Python warning categories are available as global variables whose
10501050
names are ``PyExc_`` followed by the Python exception name. These have the type
1051-
:c:type:`PyObject*`; they are all class objects. For completeness, here are all
1051+
:c:expr:`PyObject*`; they are all class objects. For completeness, here are all
10521052
the variables:
10531053
10541054
.. index::

Doc/c-api/init.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1668,7 +1668,7 @@ you need to include :file:`pythread.h` to use thread-local storage.
16681668
.. note::
16691669
None of these API functions handle memory management on behalf of the
16701670
:c:type:`void*` values. You need to allocate and deallocate them yourself.
1671-
If the :c:type:`void*` values happen to be :c:type:`PyObject*`, these
1671+
If the :c:type:`void*` values happen to be :c:expr:`PyObject*`, these
16721672
functions don't do refcount operations on them either.
16731673
16741674
.. _thread-specific-storage-api:

Doc/c-api/intro.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ Objects, Types and Reference Counts
229229
.. index:: object: type
230230

231231
Most Python/C API functions have one or more arguments as well as a return value
232-
of type :c:type:`PyObject*`. This type is a pointer to an opaque data type
232+
of type :c:expr:`PyObject*`. This type is a pointer to an opaque data type
233233
representing an arbitrary Python object. Since all Python object types are
234234
treated the same way by the Python language in most situations (e.g.,
235235
assignments, scope rules, and argument passing), it is only fitting that they
236236
should be represented by a single C type. Almost all Python objects live on the
237237
heap: you never declare an automatic or static variable of type
238-
:c:type:`PyObject`, only pointer variables of type :c:type:`PyObject*` can be
238+
:c:type:`PyObject`, only pointer variables of type :c:expr:`PyObject*` can be
239239
declared. The sole exception are the type objects; since these must never be
240240
deallocated, they are typically static :c:type:`PyTypeObject` objects.
241241

Doc/c-api/structures.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ the definition of all other Python objects.
2727
object. In a normal "release" build, it contains only the object's
2828
reference count and a pointer to the corresponding type object.
2929
Nothing is actually declared to be a :c:type:`PyObject`, but every pointer
30-
to a Python object can be cast to a :c:type:`PyObject*`. Access to the
30+
to a Python object can be cast to a :c:expr:`PyObject*`. Access to the
3131
members must be done by using the macros :c:macro:`Py_REFCNT` and
3232
:c:macro:`Py_TYPE`.
3333

@@ -172,7 +172,7 @@ Implementing functions and methods
172172
.. c:type:: PyCFunction
173173
174174
Type of the functions used to implement most Python callables in C.
175-
Functions of this type take two :c:type:`PyObject*` parameters and return
175+
Functions of this type take two :c:expr:`PyObject*` parameters and return
176176
one such value. If the return value is ``NULL``, an exception shall have
177177
been set. If not ``NULL``, the return value is interpreted as the return
178178
value of the function as exposed in Python. The function must return a new
@@ -251,10 +251,10 @@ Implementing functions and methods
251251
+------------------+---------------+-------------------------------+
252252
253253
The :attr:`ml_meth` is a C function pointer. The functions may be of different
254-
types, but they always return :c:type:`PyObject*`. If the function is not of
254+
types, but they always return :c:expr:`PyObject*`. If the function is not of
255255
the :c:type:`PyCFunction`, the compiler will require a cast in the method table.
256256
Even though :c:type:`PyCFunction` defines the first parameter as
257-
:c:type:`PyObject*`, it is common that the method implementation uses the
257+
:c:expr:`PyObject*`, it is common that the method implementation uses the
258258
specific C type of the *self* object.
259259
260260
The :attr:`ml_flags` field is a bitfield which can include the following flags.
@@ -266,7 +266,7 @@ There are these calling conventions:
266266
.. data:: METH_VARARGS
267267
268268
This is the typical calling convention, where the methods have the type
269-
:c:type:`PyCFunction`. The function expects two :c:type:`PyObject*` values.
269+
:c:type:`PyCFunction`. The function expects two :c:expr:`PyObject*` values.
270270
The first one is the *self* object for methods; for module functions, it is
271271
the module object. The second parameter (often called *args*) is a tuple
272272
object representing all arguments. This parameter is typically processed
@@ -287,7 +287,7 @@ There are these calling conventions:
287287
Fast calling convention supporting only positional arguments.
288288
The methods have the type :c:type:`_PyCFunctionFast`.
289289
The first parameter is *self*, the second parameter is a C array
290-
of :c:type:`PyObject*` values indicating the arguments and the third
290+
of :c:expr:`PyObject*` values indicating the arguments and the third
291291
parameter is the number of arguments (the length of the array).
292292
293293
.. versionadded:: 3.7
@@ -303,7 +303,7 @@ There are these calling conventions:
303303
with methods of type :c:type:`_PyCFunctionFastWithKeywords`.
304304
Keyword arguments are passed the same way as in the
305305
:ref:`vectorcall protocol <vectorcall>`:
306-
there is an additional fourth :c:type:`PyObject*` parameter
306+
there is an additional fourth :c:expr:`PyObject*` parameter
307307
which is a tuple representing the names of the keyword arguments
308308
(which are guaranteed to be strings)
309309
or possibly ``NULL`` if there are no keywords. The values of the keyword
@@ -339,7 +339,7 @@ There are these calling conventions:
339339
Methods with a single object argument can be listed with the :const:`METH_O`
340340
flag, instead of invoking :c:func:`PyArg_ParseTuple` with a ``"O"`` argument.
341341
They have the type :c:type:`PyCFunction`, with the *self* parameter, and a
342-
:c:type:`PyObject*` parameter representing the single argument.
342+
:c:expr:`PyObject*` parameter representing the single argument.
343343
344344
345345
These two constants are not used to indicate the calling convention but the
@@ -505,15 +505,15 @@ Accessing attributes of extension types
505505
| | | getter and setter |
506506
+-------------+------------------+-----------------------------------+
507507
508-
The ``get`` function takes one :c:type:`PyObject*` parameter (the
508+
The ``get`` function takes one :c:expr:`PyObject*` parameter (the
509509
instance) and a function pointer (the associated ``closure``)::
510510
511511
typedef PyObject *(*getter)(PyObject *, void *);
512512
513513
It should return a new reference on success or ``NULL`` with a set exception
514514
on failure.
515515
516-
``set`` functions take two :c:type:`PyObject*` parameters (the instance and
516+
``set`` functions take two :c:expr:`PyObject*` parameters (the instance and
517517
the value to be set) and a function pointer (the associated ``closure``)::
518518
519519
typedef int (*setter)(PyObject *, PyObject *, void *);

Doc/c-api/tuple.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ type.
161161
.. c:type:: PyStructSequence_Field
162162
163163
Describes a field of a struct sequence. As a struct sequence is modeled as a
164-
tuple, all fields are typed as :c:type:`PyObject*`. The index in the
164+
tuple, all fields are typed as :c:expr:`PyObject*`. The index in the
165165
:attr:`fields` array of the :c:type:`PyStructSequence_Desc` determines which
166166
field of the struct sequence is described.
167167

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ and :c:type:`PyType_Type` effectively act as defaults.)
14841484
than zero and contains the offset in the instance structure of the weak
14851485
reference list head (ignoring the GC header, if present); this offset is used by
14861486
:c:func:`PyObject_ClearWeakRefs` and the :c:func:`PyWeakref_\*` functions. The
1487-
instance structure needs to include a field of type :c:type:`PyObject*` which is
1487+
instance structure needs to include a field of type :c:expr:`PyObject*` which is
14881488
initialized to ``NULL``.
14891489

14901490
Do not confuse this field with :c:member:`~PyTypeObject.tp_weaklist`; that is the list head for

Doc/library/ctypes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,8 +2367,8 @@ These are the fundamental ctypes data types:
23672367

23682368
.. class:: py_object
23692369

2370-
Represents the C :c:type:`PyObject *` datatype. Calling this without an
2371-
argument creates a ``NULL`` :c:type:`PyObject *` pointer.
2370+
Represents the C :c:expr:`PyObject *` datatype. Calling this without an
2371+
argument creates a ``NULL`` :c:expr:`PyObject *` pointer.
23722372

23732373
The :mod:`ctypes.wintypes` module provides quite some other Windows specific
23742374
data types, for example :c:type:`HWND`, :c:type:`WPARAM`, or :c:type:`DWORD`. Some

0 commit comments

Comments
 (0)