gh-111262: Make PyDict_Pop() public by scoder · Pull Request #111263 · python/cpython
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change lacks tests.
| .. versionadded:: 3.4 | ||
|
|
||
|
|
||
| .. c:function:: PyObject* PyDict_Pop(PyObject *p, PyObject *key, PyObject *defaultobj) |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to return -1 on error, 0 if the key doesn't exist, 1 if the key exists.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would the caller know the popped value then?
| { | ||
| if (!PyDict_Check(dict)) { | ||
| PyErr_BadInternalCall(); | ||
| return -1; |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should certainly be return NULL?
I created PR #111939 based on this PR: I changed the API and added tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters