mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-111262: Add PyDict_Pop() function (#112028)
_PyDict_Pop_KnownHash(): remove the default value and the return type becomes an int. Co-authored-by: Stefan Behnel <stefan_ml@behnel.de> Co-authored-by: Antoine Pitrou <pitrou@free.fr>
This commit is contained in:
parent
f44d6ff6e0
commit
4f04172c92
15 changed files with 338 additions and 76 deletions
|
@ -1049,7 +1049,10 @@ _odict_popkey_hash(PyObject *od, PyObject *key, PyObject *failobj,
|
|||
return NULL;
|
||||
}
|
||||
/* Now delete the value from the dict. */
|
||||
value = _PyDict_Pop_KnownHash(od, key, hash, failobj);
|
||||
if (_PyDict_Pop_KnownHash((PyDictObject *)od, key, hash,
|
||||
&value) == 0) {
|
||||
value = Py_NewRef(failobj);
|
||||
}
|
||||
}
|
||||
else if (value == NULL && !PyErr_Occurred()) {
|
||||
/* Apply the fallback value, if necessary. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue