(original) (raw)

changeset: 101227:3fe1c7ad3b58 parent: 101225:89116bd505cb parent: 101226:a98ef122d73d user: Serhiy Storchaka storchaka@gmail.com date: Wed May 04 21:42:52 2016 +0300 files: Misc/NEWS Objects/descrobject.c description: Issue #26811: gc.get_objects() no longer contains a broken tuple with NULL pointer. diff -r 89116bd505cb -r 3fe1c7ad3b58 Misc/NEWS --- a/Misc/NEWS Wed May 04 12:00:32 2016 -0400 +++ b/Misc/NEWS Wed May 04 21:42:52 2016 +0300 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #26811: gc.get_objects() no longer contains a broken tuple with NULL + pointer. + - Issue #20120: Use RawConfigParser for .pypirc parsing, removing support for interpolation unintentionally added with move to Python 3. Behavior no longer does any diff -r 89116bd505cb -r 3fe1c7ad3b58 Objects/descrobject.c --- a/Objects/descrobject.c Wed May 04 12:00:32 2016 -0400 +++ b/Objects/descrobject.c Wed May 04 21:42:52 2016 +0300 @@ -1386,27 +1386,27 @@ 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); } - Py_DECREF(args); + else { + assert(Py_REFCNT(args) >= 1); + _PyObject_GC_TRACK(args); + Py_DECREF(args); + } return ret; } /storchaka@gmail.com