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

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

Issue 13583: sqlite3.Row doesn't support slice indexes
Patch Set: Created 8 years, 2 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 item = PyTuple_GetItem(self->data, i); 118 item = PyTuple_GetItem(self->data, i);
119 Py_INCREF(item); 119 Py_INCREF(item);
120 return item; 120 return item;
121 } 121 }
122 122
123 } 123 }
124 124
125 PyErr_SetString(PyExc_IndexError, "No item with that key"); 125 PyErr_SetString(PyExc_IndexError, "No item with that key");
126 return NULL; 126 return NULL;
127 } else if (PySlice_Check(idx)) { 127 } else if (PySlice_Check(idx)) {
128 PyErr_SetString(PyExc_ValueError, "slices not implemented, yet"); 128 Py_ssize_t start, stop, step, slicelength;
129 return NULL; 129 if (PySlice_GetIndicesEx((PySliceObject*)idx,
130 PyTuple_GET_SIZE(self->data),
131 &start, &stop, &step, &slicelength) < 0) {
132 return NULL;
133 }
134 return PyTuple_GetSlice(self->data, start, stop);
130 } else { 135 } else {
131 PyErr_SetString(PyExc_IndexError, "Index must be int or string"); 136 PyErr_SetString(PyExc_IndexError, "Index must be int or string");
132 return NULL; 137 return NULL;
133 } 138 }
134 } 139 }
135 140
136 Py_ssize_t pysqlite_row_length(pysqlite_Row* self, PyObject* args, PyObject* kwa rgs) 141 Py_ssize_t pysqlite_row_length(pysqlite_Row* self, PyObject* args, PyObject* kwa rgs)
137 { 142 {
138 return PyTuple_GET_SIZE(self->data); 143 return PyTuple_GET_SIZE(self->data);
139 } 144 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 0, /* tp_new */ 252 0, /* tp_new */
248 0 /* tp_free */ 253 0 /* tp_free */
249 }; 254 };
250 255
251 extern int pysqlite_row_setup_types(void) 256 extern int pysqlite_row_setup_types(void)
252 { 257 {
253 pysqlite_RowType.tp_new = PyType_GenericNew; 258 pysqlite_RowType.tp_new = PyType_GenericNew;
254 pysqlite_RowType.tp_as_mapping = &pysqlite_row_as_mapping; 259 pysqlite_RowType.tp_as_mapping = &pysqlite_row_as_mapping;
255 return PyType_Ready(&pysqlite_RowType); 260 return PyType_Ready(&pysqlite_RowType);
256 } 261 }
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+