Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(12)

Side by Side Diff: Modules/_sqlite/row.c

Issue 13583: sqlite3.Row doesn't support slice indexes
Patch Set: Created 4 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/sqlite3/test/factory.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* row.c - an enhanced tuple for database rows 1 /* row.c - an enhanced tuple for database rows
2 * 2 *
3 * Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de> 3 * Copyright (C) 2005-2010 Gerhard Häring <gh@ghaering.de>
4 * 4 *
5 * This file is part of pysqlite. 5 * This file is part of pysqlite.
6 * 6 *
7 * This software is provided 'as-is', without any express or implied 7 * This software is provided 'as-is', without any express or implied
8 * warranty. In no event will the authors be held liable for any damages 8 * warranty. In no event will the authors be held liable for any damages
9 * arising from the use of this software. 9 * arising from the use of this software.
10 * 10 *
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 Py_INCREF(item); 135 Py_INCREF(item);
136 return item; 136 return item;
137 } 137 }
138 138
139 } 139 }
140 140
141 PyErr_SetString(PyExc_IndexError, "No item with that key"); 141 PyErr_SetString(PyExc_IndexError, "No item with that key");
142 return NULL; 142 return NULL;
143 } 143 }
144 else if (PySlice_Check(idx)) { 144 else if (PySlice_Check(idx)) {
145 PyErr_SetString(PyExc_ValueError, "slices not implemented, yet"); 145 return PyObject_GetItem(self->data, idx);
146 return NULL;
147 } 146 }
148 else { 147 else {
149 PyErr_SetString(PyExc_IndexError, "Index must be int or string"); 148 PyErr_SetString(PyExc_IndexError, "Index must be int or string");
150 return NULL; 149 return NULL;
151 } 150 }
152 } 151 }
153 152
154 Py_ssize_t pysqlite_row_length(pysqlite_Row* self, PyObject* args, PyObject* kwa rgs) 153 Py_ssize_t pysqlite_row_length(pysqlite_Row* self, PyObject* args, PyObject* kwa rgs)
155 { 154 {
156 return PyTuple_GET_SIZE(self->data); 155 return PyTuple_GET_SIZE(self->data);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 0 /* tp_free */ 271 0 /* tp_free */
273 }; 272 };
274 273
275 extern int pysqlite_row_setup_types(void) 274 extern int pysqlite_row_setup_types(void)
276 { 275 {
277 pysqlite_RowType.tp_new = pysqlite_row_new; 276 pysqlite_RowType.tp_new = pysqlite_row_new;
278 pysqlite_RowType.tp_as_mapping = &pysqlite_row_as_mapping; 277 pysqlite_RowType.tp_as_mapping = &pysqlite_row_as_mapping;
279 pysqlite_RowType.tp_as_sequence = &pysqlite_row_as_sequence; 278 pysqlite_RowType.tp_as_sequence = &pysqlite_row_as_sequence;
280 return PyType_Ready(&pysqlite_RowType); 279 return PyType_Ready(&pysqlite_RowType);
281 } 280 }
OLDNEW
« no previous file with comments | « Lib/sqlite3/test/factory.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+