Skip to content

Commit 20ce62f

Browse files
authored
bpo-41802: Document 'PyDict_DelItem' can raise a 'KeyError' (pythonGH-22291)
1 parent 583ee5a commit 20ce62f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Doc/c-api/dict.rst

+6-4
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ Dictionary Objects
8181
.. c:function:: int PyDict_DelItem(PyObject *p, PyObject *key)
8282
8383
Remove the entry in dictionary *p* with key *key*. *key* must be hashable;
84-
if it isn't, :exc:`TypeError` is raised. Return ``0`` on success or ``-1``
85-
on failure.
84+
if it isn't, :exc:`TypeError` is raised.
85+
If *key* is not in the dictionary, :exc:`KeyError` is raised.
86+
Return ``0`` on success or ``-1`` on failure.
8687
8788
8889
.. c:function:: int PyDict_DelItemString(PyObject *p, const char *key)
8990
90-
Remove the entry in dictionary *p* which has a key specified by the string
91-
*key*. Return ``0`` on success or ``-1`` on failure.
91+
Remove the entry in dictionary *p* which has a key specified by the string *key*.
92+
If *key* is not in the dictionary, :exc:`KeyError` is raised.
93+
Return ``0`` on success or ``-1`` on failure.
9294
9395
9496
.. c:function:: PyObject* PyDict_GetItem(PyObject *p, PyObject *key)

0 commit comments

Comments
 (0)