Skip to content

Commit

Permalink
_wrappers: use PyDict_GetItemStringRef instead of PyDict_GetItemString
Browse files Browse the repository at this point in the history
Signed-off-by: Filipe Laíns <[email protected]>
  • Loading branch information
FFY00 committed Sep 20, 2024
1 parent 01a2c0b commit 4b6db84
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/wrapt/_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,8 @@ static PyObject *WraptObjectProxy_reversed(
static PyObject *WraptObjectProxy_round(
WraptObjectProxyObject *self, PyObject *args)
{
int res;

PyObject *module = NULL;
PyObject *dict = NULL;
PyObject *round = NULL;
Expand All @@ -1318,14 +1320,22 @@ static PyObject *WraptObjectProxy_round(
return NULL;

dict = PyModule_GetDict(module);
round = PyDict_GetItemString(dict, "round");

#if PY_VERSION_HEX >= 0x30d0000 /* Python >=3.13 */
res = PyDict_GetItemStringRef(dict, "round", &round);
if (res != 1) {
Py_DECREF(module);
return NULL;
}
#else
round = PyDict_GetItemString(dict, "round");
if (!round) {
Py_DECREF(module);
return NULL;
}

Py_INCREF(round);
#endif

Py_DECREF(module);

result = PyObject_CallFunctionObjArgs(round, self->wrapped, NULL);
Expand Down

0 comments on commit 4b6db84

Please sign in to comment.