diff options
Diffstat (limited to 'Doc/c-api')
-rw-r--r-- | Doc/c-api/codec.rst | 8 | ||||
-rw-r--r-- | Doc/c-api/decimal.rst | 6 | ||||
-rw-r--r-- | Doc/c-api/dict.rst | 10 | ||||
-rw-r--r-- | Doc/c-api/gen.rst | 15 | ||||
-rw-r--r-- | Doc/c-api/iter.rst | 18 |
5 files changed, 35 insertions, 22 deletions
diff --git a/Doc/c-api/codec.rst b/Doc/c-api/codec.rst index 172dcb326a..235c77c945 100644 --- a/Doc/c-api/codec.rst +++ b/Doc/c-api/codec.rst @@ -10,6 +10,14 @@ Codec registry and support functions As side effect, this tries to load the :mod:`encodings` package, if not yet done, to make sure that it is always first in the list of search functions. +.. c:function:: int PyCodec_Unregister(PyObject *search_function) + + Unregister a codec search function and clear the registry's cache. + If the search function is not registered, do nothing. + Return 0 on success. Raise an exception and return -1 on error. + + .. versionadded:: 3.10 + .. c:function:: int PyCodec_KnownEncoding(const char *encoding) Return ``1`` or ``0`` depending on whether there is a registered codec for diff --git a/Doc/c-api/decimal.rst b/Doc/c-api/decimal.rst index f530571eba..94cc4a7b84 100644 --- a/Doc/c-api/decimal.rst +++ b/Doc/c-api/decimal.rst @@ -16,7 +16,7 @@ Initialize Typically, a C extension module that uses the decimal API will do these steps in its init function: -.. code-block:: +.. code-block:: c #include "pydecimal.h" @@ -88,7 +88,7 @@ Data structures The conversion functions use the following status codes and data structures: -.. code-block:: +.. code-block:: c /* status cases for getting a triple */ enum mpd_triple_class { @@ -126,7 +126,7 @@ Functions For simplicity, the usage of the function and all special cases are explained in code form and comments: -.. code-block:: +.. code-block:: c triple = PyDec_AsUint128Triple(dec); switch (triple.tag) { diff --git a/Doc/c-api/dict.rst b/Doc/c-api/dict.rst index 769484134e..8e0d684546 100644 --- a/Doc/c-api/dict.rst +++ b/Doc/c-api/dict.rst @@ -81,14 +81,16 @@ Dictionary Objects .. c:function:: int PyDict_DelItem(PyObject *p, PyObject *key) Remove the entry in dictionary *p* with key *key*. *key* must be hashable; - if it isn't, :exc:`TypeError` is raised. Return ``0`` on success or ``-1`` - on failure. + if it isn't, :exc:`TypeError` is raised. + If *key* is not in the dictionary, :exc:`KeyError` is raised. + Return ``0`` on success or ``-1`` on failure. .. c:function:: int PyDict_DelItemString(PyObject *p, const char *key) - Remove the entry in dictionary *p* which has a key specified by the string - *key*. Return ``0`` on success or ``-1`` on failure. + Remove the entry in dictionary *p* which has a key specified by the string *key*. + If *key* is not in the dictionary, :exc:`KeyError` is raised. + Return ``0`` on success or ``-1`` on failure. .. c:function:: PyObject* PyDict_GetItem(PyObject *p, PyObject *key) diff --git a/Doc/c-api/gen.rst b/Doc/c-api/gen.rst index e098425e63..74410927bf 100644 --- a/Doc/c-api/gen.rst +++ b/Doc/c-api/gen.rst @@ -15,11 +15,6 @@ than explicitly calling :c:func:`PyGen_New` or :c:func:`PyGen_NewWithQualName`. The C structure used for generator objects. -.. c:type:: PySendResult - - The enum value used to represent different results of :c:func:`PyGen_Send`. - - .. c:var:: PyTypeObject PyGen_Type The type object corresponding to generator objects. @@ -47,13 +42,3 @@ than explicitly calling :c:func:`PyGen_New` or :c:func:`PyGen_NewWithQualName`. with ``__name__`` and ``__qualname__`` set to *name* and *qualname*. A reference to *frame* is stolen by this function. The *frame* argument must not be ``NULL``. - -.. c:function:: PySendResult PyGen_Send(PyGenObject *gen, PyObject *arg, PyObject **presult) - - Sends the *arg* value into the generator *gen*. Coroutine objects - are also allowed to be as the *gen* argument but they need to be - explicitly casted to PyGenObject*. Returns: - - - ``PYGEN_RETURN`` if generator returns. Return value is returned via *presult*. - - ``PYGEN_NEXT`` if generator yields. Yielded value is returned via *presult*. - - ``PYGEN_ERROR`` if generator has raised and exception. *presult* is set to ``NULL``. diff --git a/Doc/c-api/iter.rst b/Doc/c-api/iter.rst index a2992b3452..68df6f6e89 100644 --- a/Doc/c-api/iter.rst +++ b/Doc/c-api/iter.rst @@ -44,3 +44,21 @@ something like this:: else { /* continue doing useful work */ } + + +.. c:type:: PySendResult + + The enum value used to represent different results of :c:func:`PyIter_Send`. + + .. versionadded:: 3.10 + + +.. c:function:: PySendResult PyIter_Send(PyObject *iter, PyObject *arg, PyObject **presult) + + Sends the *arg* value into the iterator *iter*. Returns: + + - ``PYGEN_RETURN`` if iterator returns. Return value is returned via *presult*. + - ``PYGEN_NEXT`` if iterator yields. Yielded value is returned via *presult*. + - ``PYGEN_ERROR`` if iterator has raised and exception. *presult* is set to ``NULL``. + + .. versionadded:: 3.10 |