Index: Objects/structseq.c =================================================================== --- Objects/structseq.c (revision 82641) +++ Objects/structseq.c (working copy) @@ -35,12 +35,25 @@ obj = PyObject_GC_NewVar(PyStructSequence, type, size); if (obj == NULL) return NULL; + Py_SIZE(obj) = VISIBLE_SIZE_TP(type); for (i = 0; i < size; i++) obj->ob_item[i] = NULL; return (PyObject*)obj; } +static void +structseq_dealloc(PyStructSequence *obj) +{ + Py_ssize_t i, size; + + size = REAL_SIZE(obj); + for (i = 0; i < size; ++i) { + Py_XDECREF(obj->ob_item[i]); + } + PyObject_GC_Del(obj); +} + static PyObject * structseq_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { @@ -154,8 +167,11 @@ char *cname, *crepr; cname = typ->tp_members[i].name; - if (cname == NULL) + if (cname == NULL) { + PyErr_Format(PyExc_SystemError, "In structseq_repr(), member %d name is NULL" + " for type %.500s", i, typ->tp_name); return NULL; + } val = PyStructSequence_GET_ITEM(obj, i); repr = PyObject_Repr(val); if (repr == NULL) @@ -249,7 +265,7 @@ NULL, /* tp_name */ sizeof(PyStructSequence) - sizeof(PyObject *), /* tp_basicsize */ sizeof(PyObject *), /* tp_itemsize */ - 0, /* tp_dealloc */ + (destructor)structseq_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */