summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/row.c
diff options
context:
space:
mode:
authorAnthony Baxter <anthonybaxter@gmail.com>2006-04-04 06:29:05 (GMT)
committerAnthony Baxter <anthonybaxter@gmail.com>2006-04-04 06:29:05 (GMT)
commit72289a616c90949f7a2d3b2af12cd1044e64717d (patch)
tree278f2963d2f72baad0859e6b5e9056b9daddd446 /Modules/_sqlite/row.c
parenta058836e969eba03142bc8f01418a28741f70dc3 (diff)
downloadcpython-72289a616c90949f7a2d3b2af12cd1044e64717d.zip
cpython-72289a616c90949f7a2d3b2af12cd1044e64717d.tar.gz
cpython-72289a616c90949f7a2d3b2af12cd1044e64717d.tar.bz2
Update to pysqlite 2.2.0
Diffstat (limited to 'Modules/_sqlite/row.c')
-rw-r--r--Modules/_sqlite/row.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c
index 61de801..77c7896 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 Gerhard Häring <gh@ghaering.de>
+ * Copyright (C) 2005-2006 Gerhard Häring <gh@ghaering.de>
*
* This file is part of pysqlite.
*
@@ -23,6 +23,7 @@
#include "row.h"
#include "cursor.h"
+#include "sqlitecompat.h"
void row_dealloc(Row* self)
{
@@ -78,9 +79,12 @@ PyObject* row_subscript(Row* self, PyObject* idx)
if (PyInt_Check(idx)) {
_idx = PyInt_AsLong(idx);
item = PyTuple_GetItem(self->data, _idx);
- if (item) {
- Py_INCREF(item);
- }
+ Py_XINCREF(item);
+ return item;
+ } else if (PyLong_Check(idx)) {
+ _idx = PyLong_AsLong(idx);
+ item = PyTuple_GetItem(self->data, _idx);
+ Py_XINCREF(item);
return item;
} else if (PyString_Check(idx)) {
key = PyString_AsString(idx);
@@ -89,6 +93,9 @@ PyObject* row_subscript(Row* self, PyObject* idx)
for (i = 0; i < nitems; i++) {
compare_key = PyString_AsString(PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0));
+ if (!compare_key) {
+ return NULL;
+ }
p1 = key;
p2 = compare_key;