Index: Objects/structseq.c =================================================================== --- Objects/structseq.c (revision 59950) +++ Objects/structseq.c (working copy) @@ -4,6 +4,7 @@ #include "Python.h" #include "structmember.h" #include "structseq.h" +#include "tupleobject.h" static char visible_length_key[] = "n_sequence_fields"; static char real_length_key[] = "n_fields"; @@ -111,7 +112,7 @@ else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelen, cur, i; PyObject *result; - + if (PySlice_GetIndicesEx((PySliceObject *)item, VISIBLE_SIZE(self), &start, &stop, &step, &slicelen) < 0) { @@ -147,18 +148,18 @@ Py_ssize_t len, min_len, max_len, i, n_unnamed_fields; static char *kwlist[] = {"sequence", "dict", 0}; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:structseq", + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|O:structseq", kwlist, &arg, &dict)) return NULL; arg = PySequence_Fast(arg, "constructor requires a sequence"); - if (!arg) { + if (!arg) { return NULL; } if (dict && !PyDict_Check(dict)) { - PyErr_Format(PyExc_TypeError, + PyErr_Format(PyExc_TypeError, "%.500s() takes a dict as second arg, if any", type->tp_name); Py_DECREF(arg); @@ -172,7 +173,7 @@ if (min_len != max_len) { if (len < min_len) { - PyErr_Format(PyExc_TypeError, + PyErr_Format(PyExc_TypeError, "%.500s() takes an at least %zd-sequence (%zd-sequence given)", type->tp_name, min_len, len); Py_DECREF(arg); @@ -180,16 +181,16 @@ } if (len > max_len) { - PyErr_Format(PyExc_TypeError, + PyErr_Format(PyExc_TypeError, "%.500s() takes an at most %zd-sequence (%zd-sequence given)", type->tp_name, max_len, len); Py_DECREF(arg); return NULL; } - } + } else { if (len != min_len) { - PyErr_Format(PyExc_TypeError, + PyErr_Format(PyExc_TypeError, "%.500s() takes a %zd-sequence (%zd-sequence given)", type->tp_name, min_len, len); Py_DECREF(arg); @@ -216,7 +217,7 @@ Py_INCREF(ob); res->ob_item[i] = ob; } - + Py_DECREF(arg); return (PyObject*) res; } @@ -354,7 +355,7 @@ PyObject* result; Py_ssize_t n_fields, n_visible_fields, n_unnamed_fields; int i; - + n_fields = REAL_SIZE(self); n_visible_fields = VISIBLE_SIZE(self); n_unnamed_fields = UNNAMED_FIELDS(self); @@ -373,7 +374,7 @@ Py_INCREF(self->ob_item[i]); PyTuple_SET_ITEM(tup, i, self->ob_item[i]); } - + for (; i < n_fields; i++) { char *n = Py_TYPE(self)->tp_members[i-n_unnamed_fields].name; PyDict_SetItemString(dict, n, @@ -441,7 +442,7 @@ structseq_methods, /* tp_methods */ NULL, /* tp_members */ 0, /* tp_getset */ - 0, /* tp_base */ + &PyTuple_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -482,7 +483,7 @@ members = PyMem_NEW(PyMemberDef, n_members-n_unnamed_members+1); if (members == NULL) return; - + for (i = k = 0; i < n_members; ++i) { if (desc->fields[i].name == PyStructSequence_UnnamedField) continue;