]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41802: Document 'PyDict_DelItem' can raise a 'KeyError' (GH-22291)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 2 Oct 2020 16:39:20 +0000 (09:39 -0700)
committerŁukasz Langa <lukasz@langa.pl>
Sun, 4 Oct 2020 15:30:49 +0000 (17:30 +0200)
(cherry picked from commit 20ce62f00957d11f24f6449cd5c0ef5dd67174d4)

Co-authored-by: Campbell Barton <ideasman42@gmail.com>
Doc/c-api/dict.rst

index 6b3f45e27a3cba43152877c172ea4bdee11a124f..8c626c7d4a9403cea4d1f1d392dc391c51b00d37 100644 (file)
@@ -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)