Skip to content

Commit d585c52

Browse files
Issue #28496: Mark up constants 0, 1 and -1 that denote return values or
special input values as literal text.
1 parent 5e5af96 commit d585c52

13 files changed

Lines changed: 52 additions & 52 deletions

File tree

Doc/c-api/arg.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ and the following format units are left untouched.
425425
only if its format string contains two or more format units. If the format
426426
string is empty, it returns ``None``; if it contains exactly one format
427427
unit, it returns whatever object is described by that format unit. To
428-
force it to return a tuple of size 0 or one, parenthesize the format
428+
force it to return a tuple of size ``0`` or one, parenthesize the format
429429
string.
430430
431431
When memory buffers are passed as parameters to supply data to build

Doc/c-api/buffer.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The new-style Py_buffer struct
7474
.. c:member:: int ndim
7575
7676
The number of dimensions the memory represents as a multi-dimensional
77-
array. If it is 0, :c:data:`strides` and :c:data:`suboffsets` must be
77+
array. If it is ``0``, :c:data:`strides` and :c:data:`suboffsets` must be
7878
*NULL*.
7979

8080
.. c:member:: Py_ssize_t *shape
@@ -143,7 +143,7 @@ Buffer related functions
143143

144144
.. c:function:: int PyObject_CheckBuffer(PyObject *obj)
145145
146-
Return 1 if *obj* supports the buffer interface otherwise 0.
146+
Return ``1`` if *obj* supports the buffer interface otherwise ``0``.
147147
148148
149149
.. c:function:: int PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags)
@@ -164,7 +164,7 @@ Buffer related functions
164164
:c:data:`Py_buffer` structure is filled in with non-default values and/or
165165
raise an error if the object can't support a simpler view of its memory.
166166
167-
0 is returned on success and -1 on error.
167+
``0`` is returned on success and ``-1`` on error.
168168
169169
The following table gives possible values to the *flags* arguments.
170170
@@ -273,9 +273,9 @@ Buffer related functions
273273
274274
.. c:function:: int PyBuffer_IsContiguous(Py_buffer *view, char fortran)
275275
276-
Return 1 if the memory defined by the *view* is C-style (*fortran* is
276+
Return ``1`` if the memory defined by the *view* is C-style (*fortran* is
277277
``'C'``) or Fortran-style (*fortran* is ``'F'``) contiguous or either one
278-
(*fortran* is ``'A'``). Return 0 otherwise.
278+
(*fortran* is ``'A'``). Return ``0`` otherwise.
279279
280280
281281
.. c:function:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char fortran)
@@ -289,7 +289,7 @@ Buffer related functions
289289
290290
Fill in a buffer-info structure, *view*, correctly for an exporter that can
291291
only share a contiguous chunk of memory of "unsigned bytes" of the given
292-
length. Return 0 on success and -1 (with raising an error) on error.
292+
length. Return ``0`` on success and ``-1`` (with raising an error) on error.
293293
294294
295295
MemoryView objects

Doc/c-api/capsule.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,31 +120,31 @@ Refer to :ref:`using-capsules` for more information on using these objects.
120120
guaranteed to succeed.
121121
122122
Return a nonzero value if the object is valid and matches the name passed in.
123-
Return 0 otherwise. This function will not fail.
123+
Return ``0`` otherwise. This function will not fail.
124124
125125
.. c:function:: int PyCapsule_SetContext(PyObject *capsule, void *context)
126126
127127
Set the context pointer inside *capsule* to *context*.
128128
129-
Return 0 on success. Return nonzero and set an exception on failure.
129+
Return ``0`` on success. Return nonzero and set an exception on failure.
130130
131131
.. c:function:: int PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor)
132132
133133
Set the destructor inside *capsule* to *destructor*.
134134
135-
Return 0 on success. Return nonzero and set an exception on failure.
135+
Return ``0`` on success. Return nonzero and set an exception on failure.
136136
137137
.. c:function:: int PyCapsule_SetName(PyObject *capsule, const char *name)
138138
139139
Set the name inside *capsule* to *name*. If non-*NULL*, the name must
140140
outlive the capsule. If the previous *name* stored in the capsule was not
141141
*NULL*, no attempt is made to free it.
142142
143-
Return 0 on success. Return nonzero and set an exception on failure.
143+
Return ``0`` on success. Return nonzero and set an exception on failure.
144144
145145
.. c:function:: int PyCapsule_SetPointer(PyObject *capsule, void *pointer)
146146
147147
Set the void pointer inside *capsule* to *pointer*. The pointer may not be
148148
*NULL*.
149149
150-
Return 0 on success. Return nonzero and set an exception on failure.
150+
Return ``0`` on success. Return nonzero and set an exception on failure.

Doc/c-api/conversion.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ The following functions provide locale-independent string to number conversions.
126126
127127
*format_code* must be one of ``'e'``, ``'E'``, ``'f'``, ``'F'``,
128128
``'g'``, ``'G'`` or ``'r'``. For ``'r'``, the supplied *precision*
129-
must be 0 and is ignored. The ``'r'`` format code specifies the
129+
must be ``0`` and is ignored. The ``'r'`` format code specifies the
130130
standard :func:`repr` format.
131131
132132
*flags* can be zero or more of the values *Py_DTSF_SIGN*,

Doc/c-api/file.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ change in future releases of Python.
136136
137137
.. c:function:: int PyFile_SetEncoding(PyFileObject *p, const char *enc)
138138
139-
Set the file's encoding for Unicode output to *enc*. Return 1 on success and 0
139+
Set the file's encoding for Unicode output to *enc*. Return ``1`` on success and ``0``
140140
on failure.
141141
142142
.. versionadded:: 2.3
@@ -145,7 +145,7 @@ change in future releases of Python.
145145
.. c:function:: int PyFile_SetEncodingAndErrors(PyFileObject *p, const char *enc, *errors)
146146
147147
Set the file's encoding for Unicode output to *enc*, and its error
148-
mode to *err*. Return 1 on success and 0 on failure.
148+
mode to *err*. Return ``1`` on success and ``0`` on failure.
149149
150150
.. versionadded:: 2.6
151151

Doc/c-api/import.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Importing Modules
6666
6767
.. versionchanged:: 2.6
6868
The function is an alias for :c:func:`PyImport_ImportModuleLevel` with
69-
-1 as level, meaning relative import.
69+
``-1`` as level, meaning relative import.
7070
7171
7272
.. c:function:: PyObject* PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level)

Doc/c-api/init.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ Initializing and finalizing the interpreter
4343

4444
.. c:function:: void Py_InitializeEx(int initsigs)
4545
46-
This function works like :c:func:`Py_Initialize` if *initsigs* is 1. If
47-
*initsigs* is 0, it skips initialization registration of signal handlers, which
46+
This function works like :c:func:`Py_Initialize` if *initsigs* is ``1``. If
47+
*initsigs* is ``0``, it skips initialization registration of signal handlers, which
4848
might be useful when Python is embedded.
4949
5050
.. versionadded:: 2.4
@@ -295,7 +295,7 @@ Process-wide parameters
295295
296296
.. note::
297297
It is recommended that applications embedding the Python interpreter
298-
for purposes other than executing a single script pass 0 as *updatepath*,
298+
for purposes other than executing a single script pass ``0`` as *updatepath*,
299299
and update :data:`sys.path` themselves if desired.
300300
See `CVE-2008-5983 <https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
301301
@@ -307,13 +307,13 @@ Process-wide parameters
307307
308308
.. versionadded:: 2.6.6
309309
310-
.. XXX impl. doesn't seem consistent in allowing 0/NULL for the params;
310+
.. XXX impl. doesn't seem consistent in allowing ``0``/``NULL`` for the params;
311311
check w/ Guido.
312312
313313
314314
.. c:function:: void PySys_SetArgv(int argc, char **argv)
315315
316-
This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set to 1.
316+
This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set to ``1``.
317317
318318
319319
.. c:function:: void Py_SetPythonHome(char *home)
@@ -917,8 +917,8 @@ pointer and a void pointer argument.
917917
.. index:: single: Py_AddPendingCall()
918918
919919
Schedule a function to be called from the main interpreter thread. On
920-
success, 0 is returned and *func* is queued for being called in the
921-
main thread. On failure, -1 is returned without setting any exception.
920+
success, ``0`` is returned and *func* is queued for being called in the
921+
main thread. On failure, ``-1`` is returned without setting any exception.
922922
923923
When successfully queued, *func* will be *eventually* called from the
924924
main interpreter thread with the argument *arg*. It will be called
@@ -929,7 +929,7 @@ pointer and a void pointer argument.
929929
* with the main thread holding the :term:`global interpreter lock`
930930
(*func* can therefore use the full C API).
931931
932-
*func* must return 0 on success, or -1 on failure with an exception
932+
*func* must return ``0`` on success, or ``-1`` on failure with an exception
933933
set. *func* won't be interrupted to perform another asynchronous
934934
notification recursively, but it can still be interrupted to switch
935935
threads if the global interpreter lock is released.

Doc/c-api/int.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Plain Integer Objects
8888
Will first attempt to cast the object to a :c:type:`PyIntObject`, if it is not
8989
already one, and then return its value. If there is an error, ``-1`` is
9090
returned, and the caller should check ``PyErr_Occurred()`` to find out whether
91-
there was an error, or whether the value just happened to be -1.
91+
there was an error, or whether the value just happened to be ``-1``.
9292
9393
9494
.. c:function:: long PyInt_AS_LONG(PyObject *io)

Doc/c-api/marshal.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ binary mode.
1313

1414
Numeric values are stored with the least significant byte first.
1515

16-
The module supports two versions of the data format: version 0 is the
17-
historical version, version 1 (new in Python 2.4) shares interned strings in
16+
The module supports two versions of the data format: version ``0`` is the
17+
historical version, version ``1`` (new in Python 2.4) shares interned strings in
1818
the file, and upon unmarshalling. Version 2 (new in Python 2.5) uses a binary
1919
format for floating point numbers. *Py_MARSHAL_VERSION* indicates the current
2020
file format (currently 2).

Doc/c-api/set.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ or :class:`frozenset` or instances of their subtypes.
128128
129129
.. c:function:: int PySet_Contains(PyObject *anyset, PyObject *key)
130130
131-
Return 1 if found, 0 if not found, and -1 if an error is encountered. Unlike
131+
Return ``1`` if found, ``0`` if not found, and ``-1`` if an error is encountered. Unlike
132132
the Python :meth:`__contains__` method, this function does not automatically
133133
convert unhashable sets into temporary frozensets. Raise a :exc:`TypeError` if
134134
the *key* is unhashable. Raise :exc:`PyExc_SystemError` if *anyset* is not a
@@ -138,7 +138,7 @@ or :class:`frozenset` or instances of their subtypes.
138138
.. c:function:: int PySet_Add(PyObject *set, PyObject *key)
139139
140140
Add *key* to a :class:`set` instance. Does not apply to :class:`frozenset`
141-
instances. Return 0 on success or -1 on failure. Raise a :exc:`TypeError` if
141+
instances. Return ``0`` on success or ``-1`` on failure. Raise a :exc:`TypeError` if
142142
the *key* is unhashable. Raise a :exc:`MemoryError` if there is no room to grow.
143143
Raise a :exc:`SystemError` if *set* is not an instance of :class:`set` or its
144144
subtype.
@@ -154,7 +154,7 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
154154
155155
.. c:function:: int PySet_Discard(PyObject *set, PyObject *key)
156156
157-
Return 1 if found and removed, 0 if not found (no action taken), and -1 if an
157+
Return ``1`` if found and removed, ``0`` if not found (no action taken), and ``-1`` if an
158158
error is encountered. Does not raise :exc:`KeyError` for missing keys. Raise a
159159
:exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~set.discard`
160160
method, this function does not automatically convert unhashable sets into

0 commit comments

Comments
 (0)