Commit adbe994f authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #28496: Mark up constants 0, 1 and -1 that denote return values or

special input values as literal text.
parent bae8d381
...@@ -342,7 +342,7 @@ Other objects ...@@ -342,7 +342,7 @@ Other objects
``p`` (:class:`bool`) [int] ``p`` (:class:`bool`) [int]
Tests the value passed in for truth (a boolean **p**\ redicate) and converts Tests the value passed in for truth (a boolean **p**\ redicate) and converts
the result to its equivalent C true/false integer value. the result to its equivalent C true/false integer value.
Sets the int to 1 if the expression was true and 0 if it was false. Sets the int to ``1`` if the expression was true and ``0`` if it was false.
This accepts any valid Python value. See :ref:`truth` for more This accepts any valid Python value. See :ref:`truth` for more
information about how Python tests values for truth. information about how Python tests values for truth.
......
...@@ -156,7 +156,7 @@ a buffer, see :c:func:`PyObject_GetBuffer`. ...@@ -156,7 +156,7 @@ a buffer, see :c:func:`PyObject_GetBuffer`.
.. c:member:: int ndim .. c:member:: int ndim
The number of dimensions the memory represents as an n-dimensional array. The number of dimensions the memory represents as an n-dimensional array.
If it is 0, :c:member:`~Py_buffer.buf` points to a single item representing If it is ``0``, :c:member:`~Py_buffer.buf` points to a single item representing
a scalar. In this case, :c:member:`~Py_buffer.shape`, :c:member:`~Py_buffer.strides` a scalar. In this case, :c:member:`~Py_buffer.shape`, :c:member:`~Py_buffer.strides`
and :c:member:`~Py_buffer.suboffsets` MUST be *NULL*. and :c:member:`~Py_buffer.suboffsets` MUST be *NULL*.
...@@ -427,7 +427,7 @@ Buffer-related functions ...@@ -427,7 +427,7 @@ Buffer-related functions
.. c:function:: int PyObject_CheckBuffer(PyObject *obj) .. c:function:: int PyObject_CheckBuffer(PyObject *obj)
Return 1 if *obj* supports the buffer interface otherwise 0. When 1 is Return ``1`` if *obj* supports the buffer interface otherwise ``0``. When ``1`` is
returned, it doesn't guarantee that :c:func:`PyObject_GetBuffer` will returned, it doesn't guarantee that :c:func:`PyObject_GetBuffer` will
succeed. succeed.
...@@ -437,7 +437,7 @@ Buffer-related functions ...@@ -437,7 +437,7 @@ Buffer-related functions
Send a request to *exporter* to fill in *view* as specified by *flags*. Send a request to *exporter* to fill in *view* as specified by *flags*.
If the exporter cannot provide a buffer of the exact type, it MUST raise If the exporter cannot provide a buffer of the exact type, it MUST raise
:c:data:`PyExc_BufferError`, set :c:member:`view->obj` to *NULL* and :c:data:`PyExc_BufferError`, set :c:member:`view->obj` to *NULL* and
return -1. return ``-1``.
On success, fill in *view*, set :c:member:`view->obj` to a new reference On success, fill in *view*, set :c:member:`view->obj` to a new reference
to *exporter* and return 0. In the case of chained buffer providers to *exporter* and return 0. In the case of chained buffer providers
...@@ -468,9 +468,9 @@ Buffer-related functions ...@@ -468,9 +468,9 @@ Buffer-related functions
.. c:function:: int PyBuffer_IsContiguous(Py_buffer *view, char order) .. c:function:: int PyBuffer_IsContiguous(Py_buffer *view, char order)
Return 1 if the memory defined by the *view* is C-style (*order* is Return ``1`` if the memory defined by the *view* is C-style (*order* is
``'C'``) or Fortran-style (*order* is ``'F'``) :term:`contiguous` or either one ``'C'``) or Fortran-style (*order* is ``'F'``) :term:`contiguous` or either one
(*order* is ``'A'``). Return 0 otherwise. (*order* is ``'A'``). Return ``0`` otherwise.
.. c:function:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char order) .. c:function:: void PyBuffer_FillContiguousStrides(int ndim, Py_ssize_t *shape, Py_ssize_t *strides, Py_ssize_t itemsize, char order)
...@@ -492,7 +492,7 @@ Buffer-related functions ...@@ -492,7 +492,7 @@ Buffer-related functions
On success, set :c:member:`view->obj` to a new reference to *exporter* and On success, set :c:member:`view->obj` to a new reference to *exporter* and
return 0. Otherwise, raise :c:data:`PyExc_BufferError`, set return 0. Otherwise, raise :c:data:`PyExc_BufferError`, set
:c:member:`view->obj` to *NULL* and return -1; :c:member:`view->obj` to *NULL* and return ``-1``;
If this function is used as part of a :ref:`getbufferproc <buffer-structs>`, If this function is used as part of a :ref:`getbufferproc <buffer-structs>`,
*exporter* MUST be set to the exporting object and *flags* must be passed *exporter* MUST be set to the exporting object and *flags* must be passed
......
...@@ -120,19 +120,19 @@ Refer to :ref:`using-capsules` for more information on using these objects. ...@@ -120,19 +120,19 @@ Refer to :ref:`using-capsules` for more information on using these objects.
guaranteed to succeed. guaranteed to succeed.
Return a nonzero value if the object is valid and matches the name passed in. Return a nonzero value if the object is valid and matches the name passed in.
Return 0 otherwise. This function will not fail. Return ``0`` otherwise. This function will not fail.
.. c:function:: int PyCapsule_SetContext(PyObject *capsule, void *context) .. c:function:: int PyCapsule_SetContext(PyObject *capsule, void *context)
Set the context pointer inside *capsule* to *context*. Set the context pointer inside *capsule* to *context*.
Return 0 on success. Return nonzero and set an exception on failure. Return ``0`` on success. Return nonzero and set an exception on failure.
.. c:function:: int PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor) .. c:function:: int PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor)
Set the destructor inside *capsule* to *destructor*. Set the destructor inside *capsule* to *destructor*.
Return 0 on success. Return nonzero and set an exception on failure. Return ``0`` on success. Return nonzero and set an exception on failure.
.. c:function:: int PyCapsule_SetName(PyObject *capsule, const char *name) .. c:function:: int PyCapsule_SetName(PyObject *capsule, const char *name)
...@@ -140,11 +140,11 @@ Refer to :ref:`using-capsules` for more information on using these objects. ...@@ -140,11 +140,11 @@ Refer to :ref:`using-capsules` for more information on using these objects.
outlive the capsule. If the previous *name* stored in the capsule was not outlive the capsule. If the previous *name* stored in the capsule was not
*NULL*, no attempt is made to free it. *NULL*, no attempt is made to free it.
Return 0 on success. Return nonzero and set an exception on failure. Return ``0`` on success. Return nonzero and set an exception on failure.
.. c:function:: int PyCapsule_SetPointer(PyObject *capsule, void *pointer) .. c:function:: int PyCapsule_SetPointer(PyObject *capsule, void *pointer)
Set the void pointer inside *capsule* to *pointer*. The pointer may not be Set the void pointer inside *capsule* to *pointer*. The pointer may not be
*NULL*. *NULL*.
Return 0 on success. Return nonzero and set an exception on failure. Return ``0`` on success. Return nonzero and set an exception on failure.
...@@ -185,10 +185,10 @@ Importing Modules ...@@ -185,10 +185,10 @@ Importing Modules
Return the magic number for Python bytecode files (a.k.a. :file:`.pyc` file). Return the magic number for Python bytecode files (a.k.a. :file:`.pyc` file).
The magic number should be present in the first four bytes of the bytecode The magic number should be present in the first four bytes of the bytecode
file, in little-endian byte order. Returns -1 on error. file, in little-endian byte order. Returns ``-1`` on error.
.. versionchanged:: 3.3 .. versionchanged:: 3.3
Return value of -1 upon failure. Return value of ``-1`` upon failure.
.. c:function:: const char * PyImport_GetMagicTag() .. c:function:: const char * PyImport_GetMagicTag()
......
...@@ -44,8 +44,8 @@ Initializing and finalizing the interpreter ...@@ -44,8 +44,8 @@ Initializing and finalizing the interpreter
.. c:function:: void Py_InitializeEx(int initsigs) .. c:function:: void Py_InitializeEx(int initsigs)
This function works like :c:func:`Py_Initialize` if *initsigs* is 1. If This function works like :c:func:`Py_Initialize` if *initsigs* is ``1``. If
*initsigs* is 0, it skips initialization registration of signal handlers, which *initsigs* is ``0``, it skips initialization registration of signal handlers, which
might be useful when Python is embedded. might be useful when Python is embedded.
...@@ -114,7 +114,7 @@ Process-wide parameters ...@@ -114,7 +114,7 @@ Process-wide parameters
If :c:func:`Py_Finalize` is called, this function will need to be called If :c:func:`Py_Finalize` is called, this function will need to be called
again in order to affect subsequent calls to :c:func:`Py_Initialize`. again in order to affect subsequent calls to :c:func:`Py_Initialize`.
Returns 0 if successful, a nonzero value on error (e.g. calling after the Returns ``0`` if successful, a nonzero value on error (e.g. calling after the
interpreter has already been initialized). interpreter has already been initialized).
.. versionadded:: 3.4 .. versionadded:: 3.4
...@@ -349,7 +349,7 @@ Process-wide parameters ...@@ -349,7 +349,7 @@ Process-wide parameters
- If the name of an existing script is passed in ``argv[0]``, the absolute - If the name of an existing script is passed in ``argv[0]``, the absolute
path of the directory where the script is located is prepended to path of the directory where the script is located is prepended to
:data:`sys.path`. :data:`sys.path`.
- Otherwise (that is, if *argc* is 0 or ``argv[0]`` doesn't point - Otherwise (that is, if *argc* is ``0`` or ``argv[0]`` doesn't point
to an existing file name), an empty string is prepended to to an existing file name), an empty string is prepended to
:data:`sys.path`, which is the same as prepending the current working :data:`sys.path`, which is the same as prepending the current working
directory (``"."``). directory (``"."``).
...@@ -359,7 +359,7 @@ Process-wide parameters ...@@ -359,7 +359,7 @@ Process-wide parameters
.. note:: .. note::
It is recommended that applications embedding the Python interpreter It is recommended that applications embedding the Python interpreter
for purposes other than executing a single script pass 0 as *updatepath*, for purposes other than executing a single script pass ``0`` as *updatepath*,
and update :data:`sys.path` themselves if desired. and update :data:`sys.path` themselves if desired.
See `CVE-2008-5983 <https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_. See `CVE-2008-5983 <https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
...@@ -371,14 +371,14 @@ Process-wide parameters ...@@ -371,14 +371,14 @@ Process-wide parameters
.. versionadded:: 3.1.3 .. versionadded:: 3.1.3
.. XXX impl. doesn't seem consistent in allowing 0/NULL for the params; .. XXX impl. doesn't seem consistent in allowing ``0``/``NULL`` for the params;
check w/ Guido. check w/ Guido.
.. c:function:: void PySys_SetArgv(int argc, wchar_t **argv) .. c:function:: void PySys_SetArgv(int argc, wchar_t **argv)
This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set
to 1 unless the :program:`python` interpreter was started with the to ``1`` unless the :program:`python` interpreter was started with the
:option:`-I`. :option:`-I`.
Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a
...@@ -718,10 +718,10 @@ with sub-interpreters: ...@@ -718,10 +718,10 @@ with sub-interpreters:
.. c:function:: int PyGILState_Check() .. c:function:: int PyGILState_Check()
Return 1 if the current thread is holding the GIL and 0 otherwise. Return ``1`` if the current thread is holding the GIL and ``0`` otherwise.
This function can be called from any thread at any time. This function can be called from any thread at any time.
Only if it has had its Python thread state initialized and currently is Only if it has had its Python thread state initialized and currently is
holding the GIL will it return 1. holding the GIL will it return ``1``.
This is mainly a helper/diagnostic function. It can be useful This is mainly a helper/diagnostic function. It can be useful
for example in callback contexts or memory allocation functions when for example in callback contexts or memory allocation functions when
knowing that the GIL is locked can allow the caller to perform sensitive knowing that the GIL is locked can allow the caller to perform sensitive
...@@ -991,8 +991,8 @@ pointer and a void pointer argument. ...@@ -991,8 +991,8 @@ pointer and a void pointer argument.
.. index:: single: Py_AddPendingCall() .. index:: single: Py_AddPendingCall()
Schedule a function to be called from the main interpreter thread. On Schedule a function to be called from the main interpreter thread. On
success, 0 is returned and *func* is queued for being called in the success, ``0`` is returned and *func* is queued for being called in the
main thread. On failure, -1 is returned without setting any exception. main thread. On failure, ``-1`` is returned without setting any exception.
When successfully queued, *func* will be *eventually* called from the When successfully queued, *func* will be *eventually* called from the
main interpreter thread with the argument *arg*. It will be called main interpreter thread with the argument *arg*. It will be called
...@@ -1003,7 +1003,7 @@ pointer and a void pointer argument. ...@@ -1003,7 +1003,7 @@ pointer and a void pointer argument.
* with the main thread holding the :term:`global interpreter lock` * with the main thread holding the :term:`global interpreter lock`
(*func* can therefore use the full C API). (*func* can therefore use the full C API).
*func* must return 0 on success, or -1 on failure with an exception *func* must return ``0`` on success, or ``-1`` on failure with an exception
set. *func* won't be interrupted to perform another asynchronous set. *func* won't be interrupted to perform another asynchronous
notification recursively, but it can still be interrupted to switch notification recursively, but it can still be interrupted to switch
threads if the global interpreter lock is released. threads if the global interpreter lock is released.
......
...@@ -232,7 +232,7 @@ All integers are implemented as "long" integer objects of arbitrary size. ...@@ -232,7 +232,7 @@ All integers are implemented as "long" integer objects of arbitrary size.
method (if present) to convert it to a :c:type:`PyLongObject`. method (if present) to convert it to a :c:type:`PyLongObject`.
If the value of *obj* is out of range for an :c:type:`unsigned long`, If the value of *obj* is out of range for an :c:type:`unsigned long`,
return the reduction of that value modulo :const:`ULONG_MAX + 1`. return the reduction of that value modulo ``ULONG_MAX + 1``.
.. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *obj) .. c:function:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *obj)
...@@ -242,7 +242,7 @@ All integers are implemented as "long" integer objects of arbitrary size. ...@@ -242,7 +242,7 @@ All integers are implemented as "long" integer objects of arbitrary size.
method (if present) to convert it to a :c:type:`PyLongObject`. method (if present) to convert it to a :c:type:`PyLongObject`.
If the value of *obj* is out of range for an :c:type:`unsigned long long`, If the value of *obj* is out of range for an :c:type:`unsigned long long`,
return the reduction of that value modulo :const:`PY_ULLONG_MAX + 1`. return the reduction of that value modulo ``PY_ULLONG_MAX + 1``.
.. c:function:: double PyLong_AsDouble(PyObject *pylong) .. c:function:: double PyLong_AsDouble(PyObject *pylong)
......
...@@ -266,7 +266,7 @@ Number Protocol ...@@ -266,7 +266,7 @@ Number Protocol
.. c:function:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc) .. c:function:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc)
Returns *o* converted to a Py_ssize_t value if *o* can be interpreted as an Returns *o* converted to a Py_ssize_t value if *o* can be interpreted as an
integer. If the call fails, an exception is raised and -1 is returned. integer. If the call fails, an exception is raised and ``-1`` is returned.
If *o* can be converted to a Python int but the attempt to If *o* can be converted to a Python int but the attempt to
convert to a Py_ssize_t value would raise an :exc:`OverflowError`, then the convert to a Py_ssize_t value would raise an :exc:`OverflowError`, then the
......
...@@ -114,7 +114,7 @@ or :class:`frozenset` or instances of their subtypes. ...@@ -114,7 +114,7 @@ or :class:`frozenset` or instances of their subtypes.
.. c:function:: int PySet_Contains(PyObject *anyset, PyObject *key) .. c:function:: int PySet_Contains(PyObject *anyset, PyObject *key)
Return 1 if found, 0 if not found, and -1 if an error is encountered. Unlike Return ``1`` if found, ``0`` if not found, and ``-1`` if an error is encountered. Unlike
the Python :meth:`__contains__` method, this function does not automatically the Python :meth:`__contains__` method, this function does not automatically
convert unhashable sets into temporary frozensets. Raise a :exc:`TypeError` if convert unhashable sets into temporary frozensets. Raise a :exc:`TypeError` if
the *key* is unhashable. Raise :exc:`PyExc_SystemError` if *anyset* is not a the *key* is unhashable. Raise :exc:`PyExc_SystemError` if *anyset* is not a
...@@ -125,8 +125,8 @@ or :class:`frozenset` or instances of their subtypes. ...@@ -125,8 +125,8 @@ or :class:`frozenset` or instances of their subtypes.
Add *key* to a :class:`set` instance. Also works with :class:`frozenset` Add *key* to a :class:`set` instance. Also works with :class:`frozenset`
instances (like :c:func:`PyTuple_SetItem` it can be used to fill-in the values instances (like :c:func:`PyTuple_SetItem` it can be used to fill-in the values
of brand new frozensets before they are exposed to other code). Return 0 on of brand new frozensets before they are exposed to other code). Return ``0`` on
success or -1 on failure. Raise a :exc:`TypeError` if the *key* is success or ``-1`` on failure. Raise a :exc:`TypeError` if the *key* is
unhashable. Raise a :exc:`MemoryError` if there is no room to grow. Raise a unhashable. Raise a :exc:`MemoryError` if there is no room to grow. Raise a
:exc:`SystemError` if *set* is not an instance of :class:`set` or its :exc:`SystemError` if *set* is not an instance of :class:`set` or its
subtype. subtype.
...@@ -138,7 +138,7 @@ subtypes but not for instances of :class:`frozenset` or its subtypes. ...@@ -138,7 +138,7 @@ subtypes but not for instances of :class:`frozenset` or its subtypes.
.. c:function:: int PySet_Discard(PyObject *set, PyObject *key) .. c:function:: int PySet_Discard(PyObject *set, PyObject *key)
Return 1 if found and removed, 0 if not found (no action taken), and -1 if an Return ``1`` if found and removed, ``0`` if not found (no action taken), and ``-1`` if an
error is encountered. Does not raise :exc:`KeyError` for missing keys. Raise a error is encountered. Does not raise :exc:`KeyError` for missing keys. Raise a
:exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~set.discard` :exc:`TypeError` if the *key* is unhashable. Unlike the Python :meth:`~set.discard`
method, this function does not automatically convert unhashable sets into method, this function does not automatically convert unhashable sets into
......
...@@ -32,9 +32,9 @@ Slice Objects ...@@ -32,9 +32,9 @@ Slice Objects
assuming a sequence of length *length*. Treats indices greater than assuming a sequence of length *length*. Treats indices greater than
*length* as errors. *length* as errors.
Returns 0 on success and -1 on error with no exception set (unless one of Returns ``0`` on success and ``-1`` on error with no exception set (unless one of
the indices was not :const:`None` and failed to be converted to an integer, the indices was not :const:`None` and failed to be converted to an integer,
in which case -1 is returned with an exception set). in which case ``-1`` is returned with an exception set).
You probably do not want to use this function. You probably do not want to use this function.
...@@ -51,7 +51,7 @@ Slice Objects ...@@ -51,7 +51,7 @@ Slice Objects
of bounds indices are clipped in a manner consistent with the handling of of bounds indices are clipped in a manner consistent with the handling of
normal slices. normal slices.
Returns 0 on success and -1 on error with exception set. Returns ``0`` on success and ``-1`` on error with exception set.
.. versionchanged:: 3.2 .. versionchanged:: 3.2
The parameter type for the *slice* parameter was ``PySliceObject*`` The parameter type for the *slice* parameter was ``PySliceObject*``
......
...@@ -290,7 +290,7 @@ definition with the same method name. ...@@ -290,7 +290,7 @@ definition with the same method name.
handles use of the :keyword:`del` statement on that attribute more correctly handles use of the :keyword:`del` statement on that attribute more correctly
than :c:macro:`T_OBJECT`. than :c:macro:`T_OBJECT`.
:attr:`flags` can be 0 for write and read access or :c:macro:`READONLY` for :attr:`flags` can be ``0`` for write and read access or :c:macro:`READONLY` for
read-only access. Using :c:macro:`T_STRING` for :attr:`type` implies read-only access. Using :c:macro:`T_STRING` for :attr:`type` implies
:c:macro:`READONLY`. Only :c:macro:`T_OBJECT` and :c:macro:`T_OBJECT_EX` :c:macro:`READONLY`. Only :c:macro:`T_OBJECT` and :c:macro:`T_OBJECT_EX`
members can be deleted. (They are set to *NULL*). members can be deleted. (They are set to *NULL*).
...@@ -1278,7 +1278,7 @@ Buffer Object Structures ...@@ -1278,7 +1278,7 @@ Buffer Object Structures
steps: steps:
(1) Check if the request can be met. If not, raise :c:data:`PyExc_BufferError`, (1) Check if the request can be met. If not, raise :c:data:`PyExc_BufferError`,
set :c:data:`view->obj` to *NULL* and return -1. set :c:data:`view->obj` to *NULL* and return ``-1``.
(2) Fill in the requested fields. (2) Fill in the requested fields.
...@@ -1286,7 +1286,7 @@ Buffer Object Structures ...@@ -1286,7 +1286,7 @@ Buffer Object Structures
(4) Set :c:data:`view->obj` to *exporter* and increment :c:data:`view->obj`. (4) Set :c:data:`view->obj` to *exporter* and increment :c:data:`view->obj`.
(5) Return 0. (5) Return ``0``.
If *exporter* is part of a chain or tree of buffer providers, two main If *exporter* is part of a chain or tree of buffer providers, two main
schemes can be used: schemes can be used:
...@@ -1329,7 +1329,7 @@ Buffer Object Structures ...@@ -1329,7 +1329,7 @@ Buffer Object Structures
(1) Decrement an internal counter for the number of exports. (1) Decrement an internal counter for the number of exports.
(2) If the counter is 0, free all memory associated with *view*. (2) If the counter is ``0``, free all memory associated with *view*.
The exporter MUST use the :c:member:`~Py_buffer.internal` field to keep The exporter MUST use the :c:member:`~Py_buffer.internal` field to keep
track of buffer-specific resources. This field is guaranteed to remain track of buffer-specific resources. This field is guaranteed to remain
......
...@@ -102,7 +102,7 @@ access internal read-only data of Unicode objects: ...@@ -102,7 +102,7 @@ access internal read-only data of Unicode objects:
.. XXX expand on when it is not required .. XXX expand on when it is not required
Returns 0 on success and -1 with an exception set on failure, which in Returns ``0`` on success and ``-1`` with an exception set on failure, which in
particular happens if memory allocation fails. particular happens if memory allocation fails.
.. versionadded:: 3.3 .. versionadded:: 3.3
...@@ -255,57 +255,57 @@ the Python configuration. ...@@ -255,57 +255,57 @@ the Python configuration.
.. c:function:: int Py_UNICODE_ISSPACE(Py_UNICODE ch) .. c:function:: int Py_UNICODE_ISSPACE(Py_UNICODE ch)
Return 1 or 0 depending on whether *ch* is a whitespace character. Return ``1`` or ``0`` depending on whether *ch* is a whitespace character.
.. c:function:: int Py_UNICODE_ISLOWER(Py_UNICODE ch) .. c:function:: int Py_UNICODE_ISLOWER(Py_UNICODE ch)
Return 1 or 0 depending on whether *ch* is a lowercase character. Return ``1`` or ``0`` depending on whether *ch* is a lowercase character.
.. c:function:: int Py_UNICODE_ISUPPER(Py_UNICODE ch) .. c:function:: int Py_UNICODE_ISUPPER(Py_UNICODE ch)
Return 1 or 0 depending on whether *ch* is an uppercase character. Return ``1`` or ``0`` depending on whether *ch* is an uppercase character.
.. c:function:: int Py_UNICODE_ISTITLE(Py_UNICODE ch) .. c:function:: int Py_UNICODE_ISTITLE(Py_UNICODE ch)
Return 1 or 0 depending on whether *ch* is a titlecase character. Return ``1`` or ``0`` depending on whether *ch* is a titlecase character.
.. c:function:: int Py_UNICODE_ISLINEBREAK(Py_UNICODE ch) .. c:function:: int Py_UNICODE_ISLINEBREAK(Py_UNICODE ch)
Return 1 or 0 depending on whether *ch* is a linebreak character. Return ``1`` or ``0`` depending on whether *ch* is a linebreak character.
.. c:function:: int Py_UNICODE_ISDECIMAL(Py_UNICODE ch) .. c:function:: int Py_UNICODE_ISDECIMAL(Py_UNICODE ch)
Return 1 or 0 depending on whether *ch* is a decimal character. Return ``1`` or ``0`` depending on whether *ch* is a decimal character.
.. c:function:: int Py_UNICODE_ISDIGIT(Py_UNICODE ch) .. c:function:: int Py_UNICODE_ISDIGIT(Py_UNICODE ch)
Return 1 or 0 depending on whether *ch* is a digit character. Return ``1`` or ``0`` depending on whether *ch* is a digit character.
.. c:function:: int Py_UNICODE_ISNUMERIC(Py_UNICODE ch) .. c:function:: int Py_UNICODE_ISNUMERIC(Py_UNICODE ch)
Return 1 or 0 depending on whether *ch* is a numeric character. Return ``1`` or ``0`` depending on whether *ch* is a numeric character.
.. c:function:: int Py_UNICODE_ISALPHA(Py_UNICODE ch) .. c:function:: int Py_UNICODE_ISALPHA(Py_UNICODE ch)
Return 1 or 0 depending on whether *ch* is an alphabetic character. Return ``1`` or ``0`` depending on whether *ch* is an alphabetic character.
.. c:function:: int Py_UNICODE_ISALNUM(Py_UNICODE ch) .. c:function:: int Py_UNICODE_ISALNUM(Py_UNICODE ch)
Return 1 or 0 depending on whether *ch* is an alphanumeric character. Return ``1`` or ``0`` depending on whether *ch* is an alphanumeric character.
.. c:function:: int Py_UNICODE_ISPRINTABLE(Py_UNICODE ch) .. c:function:: int Py_UNICODE_ISPRINTABLE(Py_UNICODE ch)
Return 1 or 0 depending on whether *ch* is a printable character. Return ``1`` or ``0`` depending on whether *ch* is a printable character.
Nonprintable characters are those characters defined in the Unicode character Nonprintable characters are those characters defined in the Unicode character
database as "Other" or "Separator", excepting the ASCII space (0x20) which is database as "Other" or "Separator", excepting the ASCII space (0x20) which is
considered printable. (Note that printable characters in this context are considered printable. (Note that printable characters in this context are
...@@ -903,7 +903,7 @@ wchar_t Support ...@@ -903,7 +903,7 @@ wchar_t Support
.. c:function:: PyObject* PyUnicode_FromWideChar(const wchar_t *w, Py_ssize_t size) .. c:function:: PyObject* PyUnicode_FromWideChar(const wchar_t *w, Py_ssize_t size)
Create a Unicode object from the :c:type:`wchar_t` buffer *w* of the given *size*. Create a Unicode object from the :c:type:`wchar_t` buffer *w* of the given *size*.
Passing -1 as the *size* indicates that the function must itself compute the length, Passing ``-1`` as the *size* indicates that the function must itself compute the length,
using wcslen. using wcslen.
Return *NULL* on failure. Return *NULL* on failure.
...@@ -913,7 +913,7 @@ wchar_t Support ...@@ -913,7 +913,7 @@ wchar_t Support
Copy the Unicode object contents into the :c:type:`wchar_t` buffer *w*. At most Copy the Unicode object contents into the :c:type:`wchar_t` buffer *w*. At most
*size* :c:type:`wchar_t` characters are copied (excluding a possibly trailing *size* :c:type:`wchar_t` characters are copied (excluding a possibly trailing
null termination character). Return the number of :c:type:`wchar_t` characters null termination character). Return the number of :c:type:`wchar_t` characters
copied or -1 in case of an error. Note that the resulting :c:type:`wchar_t*` copied or ``-1`` in case of an error. Note that the resulting :c:type:`wchar_t*`
string may or may not be null-terminated. It is the responsibility of the caller string may or may not be null-terminated. It is the responsibility of the caller
to make sure that the :c:type:`wchar_t*` string is null-terminated in case this is to make sure that the :c:type:`wchar_t*` string is null-terminated in case this is
required by the application. Also, note that the :c:type:`wchar_t*` string required by the application. Also, note that the :c:type:`wchar_t*` string
...@@ -1561,7 +1561,7 @@ They all return *NULL* or ``-1`` if an exception occurs. ...@@ -1561,7 +1561,7 @@ They all return *NULL* or ``-1`` if an exception occurs.
.. c:function:: PyObject* PyUnicode_Splitlines(PyObject *s, int keepend) .. c:function:: PyObject* PyUnicode_Splitlines(PyObject *s, int keepend)
Split a Unicode string at line breaks, returning a list of Unicode strings. Split a Unicode string at line breaks, returning a list of Unicode strings.
CRLF is considered to be one line break. If *keepend* is 0, the Line break CRLF is considered to be one line break. If *keepend* is ``0``, the Line break
characters are not included in the resulting strings. characters are not included in the resulting strings.
...@@ -1591,16 +1591,16 @@ They all return *NULL* or ``-1`` if an exception occurs. ...@@ -1591,16 +1591,16 @@ They all return *NULL* or ``-1`` if an exception occurs.
.. c:function:: Py_ssize_t PyUnicode_Tailmatch(PyObject *str, PyObject *substr, \ .. c:function:: Py_ssize_t PyUnicode_Tailmatch(PyObject *str, PyObject *substr, \
Py_ssize_t start, Py_ssize_t end, int direction) Py_ssize_t start, Py_ssize_t end, int direction)
Return 1 if *substr* matches ``str[start:end]`` at the given tail end Return ``1`` if *substr* matches ``str[start:end]`` at the given tail end
(*direction* == -1 means to do a prefix match, *direction* == 1 a suffix match), (*direction* == ``-1`` means to do a prefix match, *direction* == ``1`` a suffix match),
0 otherwise. Return ``-1`` if an error occurred. ``0`` otherwise. Return ``-1`` if an error occurred.
.. c:function:: Py_ssize_t PyUnicode_Find(PyObject *str, PyObject *substr, \ .. c:function:: Py_ssize_t PyUnicode_Find(PyObject *str, PyObject *substr, \
Py_ssize_t start, Py_ssize_t end, int direction) Py_ssize_t start, Py_ssize_t end, int direction)
Return the first position of *substr* in ``str[start:end]`` using the given Return the first position of *substr* in ``str[start:end]`` using the given
*direction* (*direction* == 1 means to do a forward search, *direction* == -1 a *direction* (*direction* == ``1`` means to do a forward search, *direction* == ``-1`` a
backward search). The return value is the index of the first match; a value of backward search). The return value is the index of the first match; a value of
``-1`` indicates that no match was found, and ``-2`` indicates that an error ``-1`` indicates that no match was found, and ``-2`` indicates that an error
occurred and an exception has been set. occurred and an exception has been set.
...@@ -1610,8 +1610,8 @@ They all return *NULL* or ``-1`` if an exception occurs. ...@@ -1610,8 +1610,8 @@ They all return *NULL* or ``-1`` if an exception occurs.
Py_ssize_t start, Py_ssize_t end, int direction) Py_ssize_t start, Py_ssize_t end, int direction)
Return the first position of the character *ch* in ``str[start:end]`` using Return the first position of the character *ch* in ``str[start:end]`` using
the given *direction* (*direction* == 1 means to do a forward search, the given *direction* (*direction* == ``1`` means to do a forward search,
*direction* == -1 a backward search). The return value is the index of the *direction* == ``-1`` a backward search). The return value is the index of the
first match; a value of ``-1`` indicates that no match was found, and ``-2`` first match; a value of ``-1`` indicates that no match was found, and ``-2``
indicates that an error occurred and an exception has been set. indicates that an error occurred and an exception has been set.
...@@ -1629,19 +1629,19 @@ They all return *NULL* or ``-1`` if an exception occurs. ...@@ -1629,19 +1629,19 @@ They all return *NULL* or ``-1`` if an exception occurs.
PyObject *replstr, Py_ssize_t maxcount) PyObject *replstr, Py_ssize_t maxcount)
Replace at most *maxcount* occurrences of *substr* in *str* with *replstr* and Replace at most *maxcount* occurrences of *substr* in *str* with *replstr* and
return the resulting Unicode object. *maxcount* == -1 means replace all return the resulting Unicode object. *maxcount* == ``-1`` means replace all
occurrences. occurrences.
.. c:function:: int PyUnicode_Compare(PyObject *left, PyObject *right) .. c:function:: int PyUnicode_Compare(PyObject *left, PyObject *right)
Compare two strings and return -1, 0, 1 for less than, equal, and greater than, Compare two strings and return ``-1``, ``0``, ``1`` for less than, equal, and greater than,
respectively. respectively.
.. c:function:: int PyUnicode_CompareWithASCIIString(PyObject *uni, const char *string) .. c:function:: int PyUnicode_CompareWithASCIIString(PyObject *uni, const char *string)
Compare a unicode object, *uni*, with *string* and return -1, 0, 1 for less Compare a unicode object, *uni*, with *string* and return ``-1``, ``0``, ``1`` for less
than, equal, and greater than, respectively. It is best to pass only than, equal, and greater than, respectively. It is best to pass only
ASCII-encoded strings, but the function interprets the input string as ASCII-encoded strings, but the function interprets the input string as
ISO-8859-1 if it contains non-ASCII characters. ISO-8859-1 if it contains non-ASCII characters.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment