diff options
Diffstat (limited to 'Modules/_sqlite/row.c')
-rw-r--r-- | Modules/_sqlite/row.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c index f9f57e9ffb0..3d440942f9d 100644 --- a/Modules/_sqlite/row.c +++ b/Modules/_sqlite/row.c @@ -1,6 +1,6 @@ /* row.c - an enhanced tuple for database rows * - * Copyright (C) 2005-2006 Gerhard Häring <gh@ghaering.de> + * Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de> * * This file is part of pysqlite. * @@ -83,6 +83,8 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx) return item; } else if (PyUnicode_Check(idx)) { key = _PyUnicode_AsString(idx); + if (key == NULL) + return NULL; nitems = PyTuple_Size(self->description); @@ -164,7 +166,7 @@ static PyObject* pysqlite_iter(pysqlite_Row* self) return PyObject_GetIter(self->data); } -static long pysqlite_row_hash(pysqlite_Row *self) +static Py_hash_t pysqlite_row_hash(pysqlite_Row *self) { return PyObject_Hash(self->description) ^ PyObject_Hash(self->data); } @@ -172,17 +174,17 @@ static long pysqlite_row_hash(pysqlite_Row *self) static PyObject* pysqlite_row_richcompare(pysqlite_Row *self, PyObject *_other, int opid) { if (opid != Py_EQ && opid != Py_NE) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; } if (PyType_IsSubtype(Py_TYPE(_other), &pysqlite_RowType)) { - pysqlite_Row *other = (pysqlite_Row *)_other; - PyObject *res = PyObject_RichCompare(self->description, other->description, opid); - if ((opid == Py_EQ && res == Py_True) - || (opid == Py_NE && res == Py_False)) { - Py_DECREF(res); - return PyObject_RichCompare(self->data, other->data, opid); - } + pysqlite_Row *other = (pysqlite_Row *)_other; + PyObject *res = PyObject_RichCompare(self->description, other->description, opid); + if ((opid == Py_EQ && res == Py_True) + || (opid == Py_NE && res == Py_False)) { + Py_DECREF(res); + return PyObject_RichCompare(self->data, other->data, opid); + } } Py_INCREF(Py_NotImplemented); return Py_NotImplemented; |