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

Delta Between Two Patch Sets: Modules/_sqlite/row.c

Issue 10203: sqlite3.Row doesn't support sequence protocol
Left Patch Set: Created 5 years, 3 months ago
Right Patch Set: Created 5 years, 3 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/sqlite3/test/factory.py ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 PyObject* pysqlite_row_item(pysqlite_Row* self, Py_ssize_t idx) 66 PyObject* pysqlite_row_item(pysqlite_Row* self, Py_ssize_t idx)
67 { 67 {
68 PyObject* item = PyTuple_GetItem(self->data, idx); 68 PyObject* item = PyTuple_GetItem(self->data, idx);
69 Py_XINCREF(item); 69 Py_XINCREF(item);
70 return item; 70 return item;
71 } 71 }
72 72
73 PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx) 73 PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
74 { 74 {
75 long _idx; 75 long _idx;
76 int long_overflow;
76 char* key; 77 char* key;
77 Py_ssize_t nitems, i; 78 Py_ssize_t nitems, i;
78 char* compare_key; 79 char* compare_key;
79 80
80 char* p1; 81 char* p1;
81 char* p2; 82 char* p2;
82 83
83 PyObject* item; 84 PyObject* item;
84 85
85 if (PyLong_Check(idx)) { 86 if (PyLong_Check(idx)) {
86 _idx = PyLong_AsLong(idx); 87 _idx = PyLong_AsLongAndOverflow(idx, &long_overflow);
88 if (long_overflow) {
89 PyErr_Format(PyExc_IndexError,
90 "cannot fit '%.200s' into an index-sized integer",
91 idx->ob_type->tp_name);
92 return NULL;
93 }
87 if (_idx < 0) 94 if (_idx < 0)
88 _idx += PyTuple_GET_SIZE(self->data); 95 _idx += PyTuple_GET_SIZE(self->data);
89 item = PyTuple_GetItem(self->data, _idx); 96 item = PyTuple_GetItem(self->data, _idx);
90 Py_XINCREF(item); 97 Py_XINCREF(item);
91 return item; 98 return item;
92 } else if (PyUnicode_Check(idx)) { 99 } else if (PyUnicode_Check(idx)) {
93 key = _PyUnicode_AsString(idx); 100 key = _PyUnicode_AsString(idx);
94 if (key == NULL) 101 if (key == NULL)
95 return NULL; 102 return NULL;
96 103
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 0 /* tp_free */ 271 0 /* tp_free */
265 }; 272 };
266 273
267 extern int pysqlite_row_setup_types(void) 274 extern int pysqlite_row_setup_types(void)
268 { 275 {
269 pysqlite_RowType.tp_new = PyType_GenericNew; 276 pysqlite_RowType.tp_new = PyType_GenericNew;
270 pysqlite_RowType.tp_as_mapping = &pysqlite_row_as_mapping; 277 pysqlite_RowType.tp_as_mapping = &pysqlite_row_as_mapping;
271 pysqlite_RowType.tp_as_sequence = &pysqlite_row_as_sequence; 278 pysqlite_RowType.tp_as_sequence = &pysqlite_row_as_sequence;
272 return PyType_Ready(&pysqlite_RowType); 279 return PyType_Ready(&pysqlite_RowType);
273 } 280 }
LEFTRIGHT

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