Issue #26811: gc.get_objects() no longer contains a broken tuple with… · python/cpython@7822f15 (original) (raw)

`@@ -1386,27 +1386,27 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type)

`

1386

1386

`return NULL;

`

1387

1387

` }

`

1388

1388

`args = 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)

`

1392

1393

`return NULL;

`

``

1394

`+

_PyObject_GC_UNTRACK(args);

`

1393

1395

` }

`

1394

``

`-

Py_INCREF(args);

`

1395

``

`-

assert (Py_REFCNT(args) == 2);

`

1396

1396

`Py_INCREF(obj);

`

1397

1397

`PyTuple_SET_ITEM(args, 0, obj);

`

1398

1398

`ret = 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);

`

1408

1409

` }

`

1409

``

`-

Py_DECREF(args);

`

1410

1410

`return ret;

`

1411

1411

`}

`

1412

1412

``