Commit fcce462e authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #26811: gc.get_objects() no longer contains a broken tuple with NULL

pointer.
parents ad039f75 7822f151
...@@ -10,6 +10,9 @@ Release date: tba ...@@ -10,6 +10,9 @@ Release date: tba
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #26811: gc.get_objects() no longer contains a broken tuple with NULL
pointer.
- Issue #20120: Use RawConfigParser for .pypirc parsing, - Issue #20120: Use RawConfigParser for .pypirc parsing,
removing support for interpolation unintentionally added removing support for interpolation unintentionally added
with move to Python 3. Behavior no longer does any with move to Python 3. Behavior no longer does any
......
...@@ -1386,27 +1386,27 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type) ...@@ -1386,27 +1386,27 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
return NULL; return NULL;
} }
args = cached_args; args = cached_args;
if (!args || Py_REFCNT(args) != 1) { cached_args = NULL;
Py_CLEAR(cached_args); if (!args) {
if (!(cached_args = args = PyTuple_New(1))) args = PyTuple_New(1);
if (!args)
return NULL; return NULL;
_PyObject_GC_UNTRACK(args);
} }
Py_INCREF(args);
assert (Py_REFCNT(args) == 2);
Py_INCREF(obj); Py_INCREF(obj);
PyTuple_SET_ITEM(args, 0, obj); PyTuple_SET_ITEM(args, 0, obj);
ret = PyObject_Call(gs->prop_get, args, NULL); ret = PyObject_Call(gs->prop_get, args, NULL);
if (args == cached_args) { if (cached_args == NULL && Py_REFCNT(args) == 1) {
if (Py_REFCNT(args) == 2) { assert(Py_SIZE(args) == 1);
obj = PyTuple_GET_ITEM(args, 0); assert(PyTuple_GET_ITEM(args, 0) == obj);
PyTuple_SET_ITEM(args, 0, NULL); cached_args = args;
Py_XDECREF(obj); Py_DECREF(obj);
} }
else { else {
Py_CLEAR(cached_args); assert(Py_REFCNT(args) >= 1);
} _PyObject_GC_TRACK(args);
Py_DECREF(args);
} }
Py_DECREF(args);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment