gh-106307: Add PyMapping_GetOptionalItem() by serhiy-storchaka · Pull Request #106308 · python/cpython
Replacement of PyObject_GetItem() which doesn't raise KeyError. int _PyMapping_LookupItem(PyObject *obj, PyObject *key, PyObject **result) Return 1 and set *result != NULL if a key is found. Return 0 and set *result == NULL if a key is not found; a KeyError is silenced. Return -1 and set *result == NULL if an error other than KeyError is raised.
serhiy-storchaka
changed the title
gh-106307: Add _PyMapping_LookupItem()
gh-106307: Add PyMapping_GetOptionalItem()
Co-authored-by: Carl Meyer <carl@oddbird.net> Co-authored-by: Victor Stinner <vstinner@python.org>
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