[New-bugs-announce] [issue10203] sqlite3.Row doesn't support sequence protocol

Paul Sokolovsky report at bugs.python.org
Tue Oct 26 21:11:33 CEST 2010


New submission from Paul Sokolovsky <pfalcon at users.sourceforge.net>:

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.

----------
components: Library (Lib)
messages: 119639
nosy: pfalcon
priority: normal
severity: normal
status: open
title: sqlite3.Row doesn't support sequence protocol
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10203>
_______________________________________


More information about the New-bugs-announce mailing list