[Python-checkins] bpo-41802: Document 'PyDict_DelItem' can raise a 'KeyError' (GH-22291)

Miss Islington (bot) webhook-mailer at python.org
Fri Oct 2 12:28:05 EDT 2020


https://github.com/python/cpython/commit/ab32ea8d79d6bfb6580d35bfc4aa42d2729c0bcf
commit: ab32ea8d79d6bfb6580d35bfc4aa42d2729c0bcf
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2020-10-02T09:27:38-07:00
summary:

bpo-41802: Document 'PyDict_DelItem' can raise a 'KeyError' (GH-22291)

(cherry picked from commit 20ce62f00957d11f24f6449cd5c0ef5dd67174d4)

Co-authored-by: Campbell Barton <ideasman42 at gmail.com>

files:
M Doc/c-api/dict.rst

diff --git a/Doc/c-api/dict.rst b/Doc/c-api/dict.rst
index 30905271c396a..e910324ef8b5a 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)



More information about the Python-checkins mailing list