|
8 | 8 | #include "pycore_gc.h"
|
9 | 9 | #include "pycore_object.h" // _PyObject_IS_GC()
|
10 | 10 | #include "pycore_pystate.h" // _PyInterpreterState_GET()
|
| 11 | +#include "pycore_tuple.h" // _PyTuple_FromArray() |
11 | 12 |
|
12 | 13 | typedef struct _gc_runtime_state GCState;
|
13 | 14 |
|
@@ -225,15 +226,11 @@ gc_get_referrers_impl(PyObject *module, Py_ssize_t nargs,
|
225 | 226 | PyObject *const *args)
|
226 | 227 | /*[clinic end generated code: output=1d44a7695ea25c40 input=bae96961b14a0922]*/
|
227 | 228 | {
|
228 |
| - PyObject *varargs = PyTuple_New(nargs); |
| 229 | + PyObject *varargs = _PyTuple_FromArray(args, nargs); |
229 | 230 |
|
230 | 231 | if (!varargs) {
|
231 | 232 | return NULL;
|
232 | 233 | }
|
233 |
| - for (Py_ssize_t i = 0; i < nargs; i++) { |
234 |
| - PyTuple_SET_ITEM(varargs, i, Py_NewRef(args[i])); |
235 |
| - } |
236 |
| - |
237 | 234 | if (PySys_Audit("gc.get_referrers", "(O)", varargs) < 0) {
|
238 | 235 | Py_DECREF(varargs);
|
239 | 236 | return NULL;
|
@@ -287,15 +284,11 @@ gc_get_referents_impl(PyObject *module, Py_ssize_t nargs,
|
287 | 284 | PyObject *const *args)
|
288 | 285 | /*[clinic end generated code: output=e459f3e8c0d19311 input=b3ceab0c34038cbf]*/
|
289 | 286 | {
|
290 |
| - PyObject *varargs = PyTuple_New(nargs); |
| 287 | + PyObject *varargs = _PyTuple_FromArray(args, nargs); |
291 | 288 |
|
292 | 289 | if (!varargs) {
|
293 | 290 | return NULL;
|
294 | 291 | }
|
295 |
| - for (Py_ssize_t i = 0; i < nargs; i++) { |
296 |
| - PyTuple_SET_ITEM(varargs, i, Py_NewRef(args[i])); |
297 |
| - } |
298 |
| - |
299 | 292 | if (PySys_Audit("gc.get_referents", "(O)", varargs) < 0) {
|
300 | 293 | Py_DECREF(varargs);
|
301 | 294 | return NULL;
|
|
0 commit comments