Skip to content

Commit e48d6df

Browse files
ambvAA-Turner
authored andcommitted
[3.11] gh-93738: Documentation C syntax (:c:type:<C type> -> :c:expr:<C type>) (GH-97768) (#97924)
:c:type:`<C type>` -> :c:expr:`<C type>` Co-authored-by: Łukasz Langa <[email protected]> (cherry picked from commit 0031e62) Co-authored-by: Adam Turner <[email protected]>
1 parent 82f663b commit e48d6df

34 files changed

+240
-240
lines changed

Doc/c-api/arg.rst

+36-36
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,10 @@ which disallows mutable objects such as :class:`bytearray`.
194194
It only works for encoded data without embedded NUL bytes.
195195

196196
This format requires two arguments. The first is only used as input, and
197-
must be a :c:type:`const char*` which points to the name of an encoding as a
197+
must be a :c:expr:`const char*` which points to the name of an encoding as a
198198
NUL-terminated string, or ``NULL``, in which case ``'utf-8'`` encoding is used.
199199
An exception is raised if the named encoding is not known to Python. The
200-
second argument must be a :c:type:`char**`; the value of the pointer it
200+
second argument must be a :c:expr:`char**`; the value of the pointer it
201201
references will be set to a buffer with the contents of the argument text.
202202
The text will be encoded in the encoding specified by the first argument.
203203

@@ -217,10 +217,10 @@ which disallows mutable objects such as :class:`bytearray`.
217217
characters.
218218

219219
It requires three arguments. The first is only used as input, and must be a
220-
:c:type:`const char*` which points to the name of an encoding as a
220+
:c:expr:`const char*` which points to the name of an encoding as a
221221
NUL-terminated string, or ``NULL``, in which case ``'utf-8'`` encoding is used.
222222
An exception is raised if the named encoding is not known to Python. The
223-
second argument must be a :c:type:`char**`; the value of the pointer it
223+
second argument must be a :c:expr:`char**`; the value of the pointer it
224224
references will be set to a buffer with the contents of the argument text.
225225
The text will be encoded in the encoding specified by the first argument.
226226
The third argument must be a pointer to an integer; the referenced integer
@@ -252,59 +252,59 @@ Numbers
252252

253253
``b`` (:class:`int`) [unsigned char]
254254
Convert a nonnegative Python integer to an unsigned tiny int, stored in a C
255-
:c:type:`unsigned char`.
255+
:c:expr:`unsigned char`.
256256

257257
``B`` (:class:`int`) [unsigned char]
258258
Convert a Python integer to a tiny int without overflow checking, stored in a C
259-
:c:type:`unsigned char`.
259+
:c:expr:`unsigned char`.
260260

261261
``h`` (:class:`int`) [short int]
262-
Convert a Python integer to a C :c:type:`short int`.
262+
Convert a Python integer to a C :c:expr:`short int`.
263263

264264
``H`` (:class:`int`) [unsigned short int]
265-
Convert a Python integer to a C :c:type:`unsigned short int`, without overflow
265+
Convert a Python integer to a C :c:expr:`unsigned short int`, without overflow
266266
checking.
267267

268268
``i`` (:class:`int`) [int]
269-
Convert a Python integer to a plain C :c:type:`int`.
269+
Convert a Python integer to a plain C :c:expr:`int`.
270270

271271
``I`` (:class:`int`) [unsigned int]
272-
Convert a Python integer to a C :c:type:`unsigned int`, without overflow
272+
Convert a Python integer to a C :c:expr:`unsigned int`, without overflow
273273
checking.
274274

275275
``l`` (:class:`int`) [long int]
276-
Convert a Python integer to a C :c:type:`long int`.
276+
Convert a Python integer to a C :c:expr:`long int`.
277277

278278
``k`` (:class:`int`) [unsigned long]
279-
Convert a Python integer to a C :c:type:`unsigned long` without
279+
Convert a Python integer to a C :c:expr:`unsigned long` without
280280
overflow checking.
281281

282282
``L`` (:class:`int`) [long long]
283-
Convert a Python integer to a C :c:type:`long long`.
283+
Convert a Python integer to a C :c:expr:`long long`.
284284

285285
``K`` (:class:`int`) [unsigned long long]
286-
Convert a Python integer to a C :c:type:`unsigned long long`
286+
Convert a Python integer to a C :c:expr:`unsigned long long`
287287
without overflow checking.
288288

289289
``n`` (:class:`int`) [:c:type:`Py_ssize_t`]
290290
Convert a Python integer to a C :c:type:`Py_ssize_t`.
291291

292292
``c`` (:class:`bytes` or :class:`bytearray` of length 1) [char]
293293
Convert a Python byte, represented as a :class:`bytes` or
294-
:class:`bytearray` object of length 1, to a C :c:type:`char`.
294+
:class:`bytearray` object of length 1, to a C :c:expr:`char`.
295295

296296
.. versionchanged:: 3.3
297297
Allow :class:`bytearray` objects.
298298

299299
``C`` (:class:`str` of length 1) [int]
300300
Convert a Python character, represented as a :class:`str` object of
301-
length 1, to a C :c:type:`int`.
301+
length 1, to a C :c:expr:`int`.
302302

303303
``f`` (:class:`float`) [float]
304-
Convert a Python floating point number to a C :c:type:`float`.
304+
Convert a Python floating point number to a C :c:expr:`float`.
305305

306306
``d`` (:class:`float`) [double]
307-
Convert a Python floating point number to a C :c:type:`double`.
307+
Convert a Python floating point number to a C :c:expr:`double`.
308308

309309
``D`` (:class:`complex`) [Py_complex]
310310
Convert a Python complex number to a C :c:type:`Py_complex` structure.
@@ -329,13 +329,13 @@ Other objects
329329
``O&`` (object) [*converter*, *anything*]
330330
Convert a Python object to a C variable through a *converter* function. This
331331
takes two arguments: the first is a function, the second is the address of a C
332-
variable (of arbitrary type), converted to :c:type:`void *`. The *converter*
332+
variable (of arbitrary type), converted to :c:expr:`void *`. The *converter*
333333
function in turn is called as follows::
334334

335335
status = converter(object, address);
336336

337337
where *object* is the Python object to be converted and *address* is the
338-
:c:type:`void*` argument that was passed to the :c:func:`PyArg_Parse\*` function.
338+
:c:expr:`void*` argument that was passed to the ``PyArg_Parse*`` function.
339339
The returned *status* should be ``1`` for a successful conversion and ``0`` if
340340
the conversion has failed. When the conversion fails, the *converter* function
341341
should raise an exception and leave the content of *address* unmodified.
@@ -568,7 +568,7 @@ Building values
568568
Same as ``s#``.
569569
570570
``u`` (:class:`str`) [const wchar_t \*]
571-
Convert a null-terminated :c:type:`wchar_t` buffer of Unicode (UTF-16 or UCS-4)
571+
Convert a null-terminated :c:expr:`wchar_t` buffer of Unicode (UTF-16 or UCS-4)
572572
data to a Python Unicode object. If the Unicode buffer pointer is ``NULL``,
573573
``None`` is returned.
574574
@@ -584,51 +584,51 @@ Building values
584584
Same as ``s#``.
585585
586586
``i`` (:class:`int`) [int]
587-
Convert a plain C :c:type:`int` to a Python integer object.
587+
Convert a plain C :c:expr:`int` to a Python integer object.
588588
589589
``b`` (:class:`int`) [char]
590-
Convert a plain C :c:type:`char` to a Python integer object.
590+
Convert a plain C :c:expr:`char` to a Python integer object.
591591
592592
``h`` (:class:`int`) [short int]
593-
Convert a plain C :c:type:`short int` to a Python integer object.
593+
Convert a plain C :c:expr:`short int` to a Python integer object.
594594
595595
``l`` (:class:`int`) [long int]
596-
Convert a C :c:type:`long int` to a Python integer object.
596+
Convert a C :c:expr:`long int` to a Python integer object.
597597
598598
``B`` (:class:`int`) [unsigned char]
599-
Convert a C :c:type:`unsigned char` to a Python integer object.
599+
Convert a C :c:expr:`unsigned char` to a Python integer object.
600600
601601
``H`` (:class:`int`) [unsigned short int]
602-
Convert a C :c:type:`unsigned short int` to a Python integer object.
602+
Convert a C :c:expr:`unsigned short int` to a Python integer object.
603603
604604
``I`` (:class:`int`) [unsigned int]
605-
Convert a C :c:type:`unsigned int` to a Python integer object.
605+
Convert a C :c:expr:`unsigned int` to a Python integer object.
606606
607607
``k`` (:class:`int`) [unsigned long]
608-
Convert a C :c:type:`unsigned long` to a Python integer object.
608+
Convert a C :c:expr:`unsigned long` to a Python integer object.
609609
610610
``L`` (:class:`int`) [long long]
611-
Convert a C :c:type:`long long` to a Python integer object.
611+
Convert a C :c:expr:`long long` to a Python integer object.
612612
613613
``K`` (:class:`int`) [unsigned long long]
614-
Convert a C :c:type:`unsigned long long` to a Python integer object.
614+
Convert a C :c:expr:`unsigned long long` to a Python integer object.
615615
616616
``n`` (:class:`int`) [:c:type:`Py_ssize_t`]
617617
Convert a C :c:type:`Py_ssize_t` to a Python integer.
618618
619619
``c`` (:class:`bytes` of length 1) [char]
620-
Convert a C :c:type:`int` representing a byte to a Python :class:`bytes` object of
620+
Convert a C :c:expr:`int` representing a byte to a Python :class:`bytes` object of
621621
length 1.
622622
623623
``C`` (:class:`str` of length 1) [int]
624-
Convert a C :c:type:`int` representing a character to Python :class:`str`
624+
Convert a C :c:expr:`int` representing a character to Python :class:`str`
625625
object of length 1.
626626
627627
``d`` (:class:`float`) [double]
628-
Convert a C :c:type:`double` to a Python floating point number.
628+
Convert a C :c:expr:`double` to a Python floating point number.
629629
630630
``f`` (:class:`float`) [float]
631-
Convert a C :c:type:`float` to a Python floating point number.
631+
Convert a C :c:expr:`float` to a Python floating point number.
632632
633633
``D`` (:class:`complex`) [Py_complex \*]
634634
Convert a C :c:type:`Py_complex` structure to a Python complex number.
@@ -651,7 +651,7 @@ Building values
651651
652652
``O&`` (object) [*converter*, *anything*]
653653
Convert *anything* to a Python object through a *converter* function. The
654-
function is called with *anything* (which should be compatible with :c:type:`void*`)
654+
function is called with *anything* (which should be compatible with :c:expr:`void*`)
655655
as its argument and should return a "new" Python object, or ``NULL`` if an
656656
error occurred.
657657

Doc/c-api/capsule.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Refer to :ref:`using-capsules` for more information on using these objects.
1515
.. c:type:: PyCapsule
1616
1717
This subtype of :c:type:`PyObject` represents an opaque value, useful for C
18-
extension modules who need to pass an opaque value (as a :c:type:`void*`
18+
extension modules who need to pass an opaque value (as a :c:expr:`void*`
1919
pointer) through Python code to other C code. It is often used to make a C
2020
function pointer defined in one module available to other modules, so the
2121
regular import mechanism can be used to access C APIs defined in dynamically

Doc/c-api/complex.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ Complex Numbers as Python Objects
115115
116116
.. c:function:: double PyComplex_RealAsDouble(PyObject *op)
117117
118-
Return the real part of *op* as a C :c:type:`double`.
118+
Return the real part of *op* as a C :c:expr:`double`.
119119
120120
121121
.. c:function:: double PyComplex_ImagAsDouble(PyObject *op)
122122
123-
Return the imaginary part of *op* as a C :c:type:`double`.
123+
Return the imaginary part of *op* as a C :c:expr:`double`.
124124
125125
126126
.. c:function:: Py_complex PyComplex_AsCComplex(PyObject *op)

Doc/c-api/conversion.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The following functions provide locale-independent string to number conversions.
4949
5050
.. c:function:: double PyOS_string_to_double(const char *s, char **endptr, PyObject *overflow_exception)
5151
52-
Convert a string ``s`` to a :c:type:`double`, raising a Python
52+
Convert a string ``s`` to a :c:expr:`double`, raising a Python
5353
exception on failure. The set of accepted strings corresponds to
5454
the set of strings accepted by Python's :func:`float` constructor,
5555
except that ``s`` must not have leading or trailing whitespace.
@@ -83,7 +83,7 @@ The following functions provide locale-independent string to number conversions.
8383
8484
.. c:function:: char* PyOS_double_to_string(double val, char format_code, int precision, int flags, int *ptype)
8585
86-
Convert a :c:type:`double` *val* to a string using supplied
86+
Convert a :c:expr:`double` *val* to a string using supplied
8787
*format_code*, *precision*, and *flags*.
8888
8989
*format_code* must be one of ``'e'``, ``'E'``, ``'f'``, ``'F'``,

Doc/c-api/dict.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Dictionary Objects
7373
.. index:: single: PyUnicode_FromString()
7474
7575
Insert *val* into the dictionary *p* using *key* as a key. *key* should
76-
be a :c:type:`const char*`. The key object is created using
76+
be a :c:expr:`const char*`. The key object is created using
7777
``PyUnicode_FromString(key)``. Return ``0`` on success or ``-1`` on
7878
failure. This function *does not* steal a reference to *val*.
7979
@@ -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:expr:`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

Doc/c-api/file.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ the :mod:`io` APIs instead.
3838
3939
.. c:function:: int PyObject_AsFileDescriptor(PyObject *p)
4040
41-
Return the file descriptor associated with *p* as an :c:type:`int`. If the
41+
Return the file descriptor associated with *p* as an :c:expr:`int`. If the
4242
object is an integer, its value is returned. If not, the
4343
object's :meth:`~io.IOBase.fileno` method is called if it exists; the
4444
method must return an integer, which is returned as the file descriptor

Doc/c-api/float.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Floating Point Objects
4444
4545
.. c:function:: double PyFloat_AsDouble(PyObject *pyfloat)
4646
47-
Return a C :c:type:`double` representation of the contents of *pyfloat*. If
47+
Return a C :c:expr:`double` representation of the contents of *pyfloat*. If
4848
*pyfloat* is not a Python floating point object but has a :meth:`__float__`
4949
method, this method will first be called to convert *pyfloat* into a float.
5050
If ``__float__()`` is not defined then it falls back to :meth:`__index__`.
@@ -57,7 +57,7 @@ Floating Point Objects
5757
5858
.. c:function:: double PyFloat_AS_DOUBLE(PyObject *pyfloat)
5959
60-
Return a C :c:type:`double` representation of the contents of *pyfloat*, but
60+
Return a C :c:expr:`double` representation of the contents of *pyfloat*, but
6161
without error checking.
6262
6363
@@ -70,21 +70,21 @@ Floating Point Objects
7070
7171
.. c:function:: double PyFloat_GetMax()
7272
73-
Return the maximum representable finite float *DBL_MAX* as C :c:type:`double`.
73+
Return the maximum representable finite float *DBL_MAX* as C :c:expr:`double`.
7474
7575
7676
.. c:function:: double PyFloat_GetMin()
7777
78-
Return the minimum normalized positive float *DBL_MIN* as C :c:type:`double`.
78+
Return the minimum normalized positive float *DBL_MIN* as C :c:expr:`double`.
7979
8080
8181
Pack and Unpack functions
8282
=========================
8383
8484
The pack and unpack functions provide an efficient platform-independent way to
8585
store floating-point values as byte strings. The Pack routines produce a bytes
86-
string from a C :c:type:`double`, and the Unpack routines produce a C
87-
:c:type:`double` from such a bytes string. The suffix (2, 4 or 8) specifies the
86+
string from a C :c:expr:`double`, and the Unpack routines produce a C
87+
:c:expr:`double` from such a bytes string. The suffix (2, 4 or 8) specifies the
8888
number of bytes in the bytes string.
8989
9090
On platforms that appear to use IEEE 754 formats these functions work by
@@ -107,7 +107,7 @@ Pack functions
107107
--------------
108108
109109
The pack routines write 2, 4 or 8 bytes, starting at *p*. *le* is an
110-
:c:type:`int` argument, non-zero if you want the bytes string in little-endian
110+
:c:expr:`int` argument, non-zero if you want the bytes string in little-endian
111111
format (exponent last, at ``p+1``, ``p+3``, or ``p+6`` ``p+7``), zero if you
112112
want big-endian format (exponent first, at *p*). The :c:data:`PY_BIG_ENDIAN`
113113
constant can be used to use the native endian: it is equal to ``1`` on big
@@ -138,7 +138,7 @@ Unpack functions
138138
----------------
139139
140140
The unpack routines read 2, 4 or 8 bytes, starting at *p*. *le* is an
141-
:c:type:`int` argument, non-zero if the bytes string is in little-endian format
141+
:c:expr:`int` argument, non-zero if the bytes string is in little-endian format
142142
(exponent last, at ``p+1``, ``p+3`` or ``p+6`` and ``p+7``), zero if big-endian
143143
(exponent first, at *p*). The :c:data:`PY_BIG_ENDIAN` constant can be used to
144144
use the native endian: it is equal to ``1`` on big endian processor, or ``0``

0 commit comments

Comments
 (0)