summaryrefslogtreecommitdiffstats
path: root/Objects/descrobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-05-04 18:42:05 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-05-04 18:42:05 (GMT)
commit7822f151b68e40376af657d267ff774439d9adb9 (patch)
treed9012dec4ba8aefe43340c002d83ff273c19ea2a /Objects/descrobject.c
parent422cf2b4adaf8a5d69f2baf10becbe341d3ab2a4 (diff)
downloadcpython-7822f151b68e40376af657d267ff774439d9adb9.zip
cpython-7822f151b68e40376af657d267ff774439d9adb9.tar.gz
cpython-7822f151b68e40376af657d267ff774439d9adb9.tar.bz2
Issue #26811: gc.get_objects() no longer contains a broken tuple with NULL
pointer.
Diffstat (limited to 'Objects/descrobject.c')
-rw-r--r--Objects/descrobject.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index ac2752e..da68e3b 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -1386,27 +1386,27 @@ property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
return NULL;
}
args = cached_args;
- if (!args || Py_REFCNT(args) != 1) {
- Py_CLEAR(cached_args);
- if (!(cached_args = args = PyTuple_New(1)))
+ cached_args = NULL;
+ if (!args) {
+ args = PyTuple_New(1);
+ if (!args)
return NULL;
+ _PyObject_GC_UNTRACK(args);
}
- Py_INCREF(args);
- assert (Py_REFCNT(args) == 2);
Py_INCREF(obj);
PyTuple_SET_ITEM(args, 0, obj);
ret = PyObject_Call(gs->prop_get, args, NULL);
- if (args == cached_args) {
- if (Py_REFCNT(args) == 2) {
- obj = PyTuple_GET_ITEM(args, 0);
- PyTuple_SET_ITEM(args, 0, NULL);
- Py_XDECREF(obj);
- }
- else {
- Py_CLEAR(cached_args);
- }
+ if (cached_args == NULL && Py_REFCNT(args) == 1) {
+ assert(Py_SIZE(args) == 1);
+ assert(PyTuple_GET_ITEM(args, 0) == obj);
+ cached_args = args;
+ Py_DECREF(obj);
+ }
+ else {
+ assert(Py_REFCNT(args) >= 1);
+ _PyObject_GC_TRACK(args);
+ Py_DECREF(args);
}
- Py_DECREF(args);
return ret;
}