Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
gh-111262: Make PyDict_Pop() public#111263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
…have been public right away.Seepython#108449
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The change lacks tests.
@@ -173,6 +173,16 @@ Dictionary Objects | |||
.. versionadded:: 3.4 | |||
.. c:function:: PyObject* PyDict_Pop(PyObject *p, PyObject *key, PyObject *defaultobj) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 poppedvalue then?
{ | ||
if (!PyDict_Check(dict)) { | ||
PyErr_BadInternalCall(); | ||
return -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Should certainly bereturn NULL
?
I created PR#111939 based on this PR: I changed the API and added tests. |
Uh oh!
There was an error while loading.Please reload this page.
See#108449
I kept the internal function since it saves the type check on the fast path and can thus still be used internally.
📚 Documentation preview 📚:https://cpython-previews--111263.org.readthedocs.build/