aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Modules/gcmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r--Modules/gcmodule.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 57e4aae9ed5..f5fea5aa4dd 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -8,6 +8,7 @@
#include "pycore_gc.h"
#include "pycore_object.h" // _PyObject_IS_GC()
#include "pycore_pystate.h" // _PyInterpreterState_GET()
+#include "pycore_tuple.h" // _PyTuple_FromArray()
typedef struct _gc_runtime_state GCState;
@@ -221,15 +222,25 @@ Return the list of objects that directly refer to any of 'objs'.
[clinic start generated code]*/
static PyObject *
-gc_get_referrers_impl(PyObject *module, PyObject *args)
-/*[clinic end generated code: output=296a09587f6a86b5 input=bae96961b14a0922]*/
+gc_get_referrers_impl(PyObject *module, Py_ssize_t nargs,
+ PyObject *const *args)
+/*[clinic end generated code: output=1d44a7695ea25c40 input=bae96961b14a0922]*/
{
- if (PySys_Audit("gc.get_referrers", "(O)", args) < 0) {
+ PyObject *varargs = _PyTuple_FromArray(args, nargs);
+
+ if (!varargs) {
+ return NULL;
+ }
+ if (PySys_Audit("gc.get_referrers", "(O)", varargs) < 0) {
+ Py_DECREF(varargs);
return NULL;
}
PyInterpreterState *interp = _PyInterpreterState_GET();
- return _PyGC_GetReferrers(interp, args);
+ PyObject *result = _PyGC_GetReferrers(interp, varargs);
+
+ Py_DECREF(varargs);
+ return result;
}
/* Append obj to list; return true if error (out of memory), false if OK. */
@@ -269,27 +280,37 @@ Return the list of objects that are directly referred to by 'objs'.
[clinic start generated code]*/
static PyObject *
-gc_get_referents_impl(PyObject *module, PyObject *args)
-/*[clinic end generated code: output=d47dc02cefd06fe8 input=b3ceab0c34038cbf]*/
+gc_get_referents_impl(PyObject *module, Py_ssize_t nargs,
+ PyObject *const *args)
+/*[clinic end generated code: output=e459f3e8c0d19311 input=b3ceab0c34038cbf]*/
{
- if (PySys_Audit("gc.get_referents", "(O)", args) < 0) {
+ PyObject *varargs = _PyTuple_FromArray(args, nargs);
+
+ if (!varargs) {
+ return NULL;
+ }
+ if (PySys_Audit("gc.get_referents", "(O)", varargs) < 0) {
+ Py_DECREF(varargs);
return NULL;
}
PyInterpreterState *interp = _PyInterpreterState_GET();
PyObject *result = PyList_New(0);
- if (result == NULL)
+ if (result == NULL) {
+ Py_DECREF(varargs);
return NULL;
+ }
// NOTE: stop the world is a no-op in default build
_PyEval_StopTheWorld(interp);
- int err = append_referrents(result, args);
+ int err = append_referrents(result, varargs);
_PyEval_StartTheWorld(interp);
if (err < 0) {
Py_CLEAR(result);
}
+ Py_DECREF(varargs);
return result;
}