Issue #26811: gc.get_objects() no longer contains a broken tuple with… · python/cpython@7822f15
@@ -1386,27 +1386,27 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
13861386return NULL;
13871387 }
13881388args = cached_args;
1389-if (!args || Py_REFCNT(args) != 1) {
1390-Py_CLEAR(cached_args);
1391-if (!(cached_args = args = PyTuple_New(1)))
1389+cached_args = NULL;
1390+if (!args) {
1391+args = PyTuple_New(1);
1392+if (!args)
13921393return NULL;
1394+_PyObject_GC_UNTRACK(args);
13931395 }
1394-Py_INCREF(args);
1395-assert (Py_REFCNT(args) == 2);
13961396Py_INCREF(obj);
13971397PyTuple_SET_ITEM(args, 0, obj);
13981398ret = PyObject_Call(gs->prop_get, args, NULL);
1399-if (args == cached_args) {
1400-if (Py_REFCNT(args) == 2) {
1401-obj = PyTuple_GET_ITEM(args, 0);
1402-PyTuple_SET_ITEM(args, 0, NULL);
1403-Py_XDECREF(obj);
1404- }
1405-else {
1406-Py_CLEAR(cached_args);
1407- }
1399+if (cached_args == NULL && Py_REFCNT(args) == 1) {
1400+assert(Py_SIZE(args) == 1);
1401+assert(PyTuple_GET_ITEM(args, 0) == obj);
1402+cached_args = args;
1403+Py_DECREF(obj);
1404+ }
1405+else {
1406+assert(Py_REFCNT(args) >= 1);
1407+_PyObject_GC_TRACK(args);
1408+Py_DECREF(args);
14081409 }
1409-Py_DECREF(args);
14101410return ret;
14111411}
14121412