This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pfalcon
Recipients pfalcon
Date 2010-10-26.19:11:30
SpamBayes Score 5.100864e-12
Marked as misclassified No
Message-id <1288120293.93.0.799619941752.issue10203@psf.upfronthosting.co.za>
In-reply-to
Content
sqlite.Row class doesn't implement sequence protocol, which is rather unfortunate, because it is described and expected to work like a tuple, with extra mapping-like functionality.

Specific issue I hit:

Adding rows to PyGTK ListStore,

        model = gtk.ListStore(*db.getSchema())
        for r in listGen():
            model.append(r)

I get:

TypeError: expecting a sequence

Looking at PyGTK sources, append() method uses PySequence Check() on the argument. Looking at Python 2.6.5 abstract.c:

int
PySequence_Check(PyObject *s)
{
        if (s && PyInstance_Check(s))
                return PyObject_HasAttrString(s, "__getitem__");
        if (PyObject_IsInstance(s, (PyObject *)&PyDict_Type))
                return 0;
        return s != NULL && s->ob_type->tp_as_sequence &&
                s->ob_type->tp_as_sequence->sq_item != NULL;
}

And sqlite3.Row doesn't set ob_type->tp_as_sequence as of Py 2.6.5 or 2.7.
History
Date User Action Args
2010-10-26 19:11:34pfalconsetrecipients: + pfalcon
2010-10-26 19:11:33pfalconsetmessageid: <1288120293.93.0.799619941752.issue10203@psf.upfronthosting.co.za>
2010-10-26 19:11:31pfalconlinkissue10203 messages
2010-10-26 19:11:31pfalconcreate