@@ -28,9 +28,9 @@ See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` and
2828
2929.. c :function :: PyObject* PyMapping_GetItemString (PyObject *o, const char *key)
3030
31- Return element of * o * corresponding to the string *key * or `` NULL `` on failure.
32- This is the equivalent of the Python expression `` o[key] ``.
33- See also :c:func: ` PyObject_GetItem `.
31+ This is the same as :c:func: ` PyObject_GetItem `, but *key * is
32+ specified as a :c:expr: ` const char* ` UTF-8 encoded bytes string,
33+ rather than a :c:expr: ` PyObject* `.
3434
3535
3636.. c :function :: int PyMapping_GetOptionalItem (PyObject *obj, PyObject *key, PyObject **result)
@@ -50,38 +50,30 @@ See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` and
5050
5151.. c :function :: int PyMapping_GetOptionalItemString (PyObject *obj, const char *key, PyObject **result)
5252
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 ``.
53+ This is the same as :c:func: `PyMapping_GetOptionalItem `, but *key * is
54+ specified as a :c:expr: `const char* ` UTF-8 encoded bytes string,
55+ rather than a :c:expr: `PyObject* `.
6256
6357 .. versionadded :: 3.13
6458
6559
6660.. c :function :: int PyMapping_SetItemString (PyObject *o, const char *key, PyObject *v)
6761
68- Map the string *key * to the value *v * in object *o *. Returns ``-1 `` on
69- failure. This is the equivalent of the Python statement ``o[key] = v ``.
70- See also :c:func: `PyObject_SetItem `. This function *does not * steal a
71- reference to *v *.
62+ This is the same as :c:func: `PyObject_SetItem `, but *key * is
63+ specified as a :c:expr: `const char* ` UTF-8 encoded bytes string,
64+ rather than a :c:expr: `PyObject* `.
7265
7366
7467.. c :function :: int PyMapping_DelItem (PyObject *o, PyObject *key)
7568
76- Remove the mapping for the object *key * from the object *o *. Return ``-1 ``
77- on failure. This is equivalent to the Python statement ``del o[key] ``.
7869 This is an alias of :c:func: `PyObject_DelItem `.
7970
8071
8172.. c :function :: int PyMapping_DelItemString (PyObject *o, const char *key)
8273
83- Remove the mapping for the string *key * from the object *o *. Return ``-1 ``
84- on failure. This is equivalent to the Python statement ``del o[key] ``.
74+ This is the same as :c:func: `PyObject_DelItem `, but *key * is
75+ specified as a :c:expr: `const char* ` UTF-8 encoded bytes string,
76+ rather than a :c:expr: `PyObject* `.
8577
8678
8779.. c :function :: int PyMapping_HasKey (PyObject *o, PyObject *key)
@@ -90,20 +82,27 @@ See also :c:func:`PyObject_GetItem`, :c:func:`PyObject_SetItem` and
9082 This is equivalent to the Python expression ``key in o ``.
9183 This function always succeeds.
9284
93- Note that exceptions which occur while calling the :meth: `~object.__getitem__ `
94- method will get suppressed.
95- To get error reporting use :c:func: `PyObject_GetItem() ` instead.
85+ .. note ::
86+
87+ Exceptions which occur when this calls :meth: `~object.__getitem__ `
88+ method are silently ignored.
89+ For proper error handling, use :c:func: `PyMapping_GetOptionalItem ` or
90+ :c:func: `PyObject_GetItem() ` instead.
9691
9792
9893.. c :function :: int PyMapping_HasKeyString (PyObject *o, const char *key)
9994
100- Return ``1 `` if the mapping object has the key *key * and ``0 `` otherwise.
101- This is equivalent to the Python expression ``key in o ``.
102- This function always succeeds.
95+ This is the same as :c:func: `PyMapping_HasKey `, but *key * is
96+ specified as a :c:expr: `const char* ` UTF-8 encoded bytes string,
97+ rather than a :c:expr: `PyObject* `.
98+
99+ .. note ::
103100
104- Note that exceptions which occur while calling the :meth: `~object.__getitem__ `
105- method and creating a temporary string object will get suppressed.
106- To get error reporting use :c:func: `PyMapping_GetItemString() ` instead.
101+ Exceptions that occur when this calls :meth: `~object.__getitem__ `
102+ method or while creating the temporary :class: `str `
103+ object are silently ignored.
104+ For proper error handling, use :c:func: `PyMapping_GetOptionalItemString ` or
105+ :c:func: `PyMapping_GetItemString ` instead.
107106
108107
109108.. c :function :: PyObject* PyMapping_Keys (PyObject *o)
0 commit comments