From c9edb254c8c710881315ba67ec7811048761cdfb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 17 Sep 2020 20:55:55 +1000 Subject: [PATCH 1/3] Document 'PyDict_DelItem' can raise a 'KeyError' --- Doc/c-api/dict.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/dict.rst b/Doc/c-api/dict.rst index 769484134ed5154..5de5d36051af366 100644 --- a/Doc/c-api/dict.rst +++ b/Doc/c-api/dict.rst @@ -81,8 +81,8 @@ 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) From b10f88e54e0759eb57f58aa805ca3bf4850eac8a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 19 Sep 2020 11:25:43 +1000 Subject: [PATCH 2/3] Update dict.rst --- Doc/c-api/dict.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/dict.rst b/Doc/c-api/dict.rst index 5de5d36051af366..4a594d809220c84 100644 --- a/Doc/c-api/dict.rst +++ b/Doc/c-api/dict.rst @@ -81,14 +81,15 @@ 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, if key is not in the dictionary, + 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. + *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) From 1747c17dde1ea04b822b05e0993da6dfba7aa94a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Sep 2020 08:59:12 +1000 Subject: [PATCH 3/3] Update dict.rst Use new sentence based on feedback. --- Doc/c-api/dict.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Doc/c-api/dict.rst b/Doc/c-api/dict.rst index 4a594d809220c84..8e0d6845463490a 100644 --- a/Doc/c-api/dict.rst +++ b/Doc/c-api/dict.rst @@ -81,14 +81,15 @@ 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, if *key* is not in the dictionary, - :exc:`KeyError` 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*. If *key* is not in the dictionary, :exc:`KeyError` is raised. + 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.