@@ -33,6 +33,36 @@ See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` and
3333 See also :c:func: `PyObject_GetItem `.
3434
3535
36+ .. c :function :: int PyMapping_GetOptionalItem (PyObject *obj, PyObject *key, PyObject **result)
37+
38+ Variant of :c:func: `PyObject_GetItem ` which doesn't raise
39+ :exc: `KeyError ` if the key is not found.
40+
41+ If the key is found, return ``1 `` and set *\* result * to a new
42+ :term: `strong reference ` to the corresponding value.
43+ If the key is not found, return ``0 `` and set *\* result * to ``NULL ``;
44+ the :exc: `KeyError ` is silenced.
45+ If an error other than :exc: `KeyError ` is raised, return ``-1 `` and
46+ set *\* result * to ``NULL ``.
47+
48+ .. versionadded :: 3.13
49+
50+
51+ .. c :function :: int PyMapping_GetOptionalItemString (PyObject *obj, const char *key, PyObject **result)
52+
53+ Variant of :c:func: `PyMapping_GetItemString ` which doesn't raise
54+ :exc: `KeyError ` if the key is not found.
55+
56+ If the key is found, return ``1 `` and set *\* result * to a new
57+ :term: `strong reference ` to the corresponding value.
58+ If the key is not found, return ``0 `` and set *\* result * to ``NULL ``;
59+ the :exc: `KeyError ` is silenced.
60+ If an error other than :exc: `KeyError ` is raised, return ``-1 `` and
61+ set *\* result * to ``NULL ``.
62+
63+ .. versionadded :: 3.13
64+
65+
3666.. c :function :: int PyMapping_SetItemString (PyObject *o, const char *key, PyObject *v)
3767
3868 Map the string *key * to the value *v * in object *o *. Returns ``-1 `` on
0 commit comments