From 0020f725c6d2215ef16ecb230f137299361b6a97 Mon Sep 17 00:00:00 2001 From: Ankith Date: Sun, 28 Jul 2024 22:57:44 +0530 Subject: [PATCH] Use PyObject_CallOneArg where applicable --- src_c/base.c | 2 +- src_c/bufferproxy.c | 4 ++-- src_c/key.c | 12 ++++++------ src_c/rect_impl.h | 3 +-- src_c/rwobject.c | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src_c/base.c b/src_c/base.c index 7cbbdae917..573bca3aa2 100644 --- a/src_c/base.c +++ b/src_c/base.c @@ -2349,7 +2349,7 @@ MODINIT_DEFINE(base) if (!quit) { /* assertion */ goto error; } - rval = PyObject_CallFunctionObjArgs(atexit_register, quit, NULL); + rval = PyObject_CallOneArg(atexit_register, quit); Py_DECREF(atexit_register); Py_DECREF(quit); atexit_register = NULL; diff --git a/src_c/bufferproxy.c b/src_c/bufferproxy.c index a8c4a436d1..318e0ad0f4 100644 --- a/src_c/bufferproxy.c +++ b/src_c/bufferproxy.c @@ -107,7 +107,7 @@ _get_buffer_from_dict(PyObject *dict, Py_buffer *view_p, int flags) PyObject *py_rval; Py_INCREF(py_callback); - py_rval = PyObject_CallFunctionObjArgs(py_callback, obj, NULL); + py_rval = PyObject_CallOneArg(py_callback, obj); Py_DECREF(py_callback); if (!py_rval) { pgBuffer_Release(pg_dict_view_p); @@ -153,7 +153,7 @@ _release_buffer_from_dict(Py_buffer *view_p) PyObject *py_rval; Py_INCREF(py_callback); - py_rval = PyObject_CallFunctionObjArgs(py_callback, obj, NULL); + py_rval = PyObject_CallOneArg(py_callback, obj); if (py_rval) { Py_DECREF(py_rval); } diff --git a/src_c/key.c b/src_c/key.c index 3a2435d22e..44ea2457c2 100644 --- a/src_c/key.c +++ b/src_c/key.c @@ -188,8 +188,8 @@ key_get_pressed(PyObject *self, PyObject *_null) PyTuple_SET_ITEM(key_tuple, i, key_elem); } - ret_obj = PyObject_CallFunctionObjArgs((PyObject *)&pgScancodeWrapper_Type, - key_tuple, NULL); + ret_obj = + PyObject_CallOneArg((PyObject *)&pgScancodeWrapper_Type, key_tuple); Py_DECREF(key_tuple); return ret_obj; } @@ -216,8 +216,8 @@ get_just_pressed(PyObject *self, PyObject *_null) } PyTuple_SET_ITEM(key_tuple, i, key_elem); } - ret_obj = PyObject_CallFunctionObjArgs((PyObject *)&pgScancodeWrapper_Type, - key_tuple, NULL); + ret_obj = + PyObject_CallOneArg((PyObject *)&pgScancodeWrapper_Type, key_tuple); Py_DECREF(key_tuple); return ret_obj; } @@ -244,8 +244,8 @@ get_just_released(PyObject *self, PyObject *_null) } PyTuple_SET_ITEM(key_tuple, i, key_elem); } - ret_obj = PyObject_CallFunctionObjArgs((PyObject *)&pgScancodeWrapper_Type, - key_tuple, NULL); + ret_obj = + PyObject_CallOneArg((PyObject *)&pgScancodeWrapper_Type, key_tuple); Py_DECREF(key_tuple); return ret_obj; } diff --git a/src_c/rect_impl.h b/src_c/rect_impl.h index 99afafeeb3..a0d5c7d932 100644 --- a/src_c/rect_impl.h +++ b/src_c/rect_impl.h @@ -1529,8 +1529,7 @@ RectExport_RectFromObjectAndKeyFunc(PyObject *obj, PyObject *keyfunc, InnerRect *temp) { if (keyfunc) { - PyObject *obj_with_rect = PyObject_Vectorcall(keyfunc, &obj, 1, NULL); - + PyObject *obj_with_rect = PyObject_CallOneArg(keyfunc, obj); if (!obj_with_rect) { return NULL; } diff --git a/src_c/rwobject.c b/src_c/rwobject.c index f4764f29ff..a88c2495b2 100644 --- a/src_c/rwobject.c +++ b/src_c/rwobject.c @@ -342,7 +342,7 @@ _pg_rw_size(SDL_RWops *context) /* Return to original position. */ - tmp = PyObject_CallFunctionObjArgs(helper->seek, pos, NULL); + tmp = PyObject_CallOneArg(helper->seek, pos); if (!tmp) { PyErr_Print(); goto end;