mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
(cherry picked from commit 7e6ee50b6b
)
This commit is contained in:
parent
d26c2fe7a2
commit
d6daeeeb2f
3 changed files with 83 additions and 10 deletions
|
@ -132,7 +132,6 @@ static PyObject *
|
|||
pysqlite_row_subscript(pysqlite_Row *self, PyObject *idx)
|
||||
{
|
||||
Py_ssize_t _idx;
|
||||
Py_ssize_t nitems, i;
|
||||
|
||||
if (PyLong_Check(idx)) {
|
||||
_idx = PyNumber_AsSsize_t(idx, PyExc_IndexError);
|
||||
|
@ -144,9 +143,13 @@ pysqlite_row_subscript(pysqlite_Row *self, PyObject *idx)
|
|||
PyObject *item = PyTuple_GetItem(self->data, _idx);
|
||||
return Py_XNewRef(item);
|
||||
} else if (PyUnicode_Check(idx)) {
|
||||
nitems = PyTuple_Size(self->description);
|
||||
if (Py_IsNone(self->description)) {
|
||||
PyErr_Format(PyExc_IndexError, "No item with key %R", idx);
|
||||
return NULL;
|
||||
}
|
||||
Py_ssize_t nitems = PyTuple_GET_SIZE(self->description);
|
||||
|
||||
for (i = 0; i < nitems; i++) {
|
||||
for (Py_ssize_t i = 0; i < nitems; i++) {
|
||||
PyObject *obj;
|
||||
obj = PyTuple_GET_ITEM(self->description, i);
|
||||
obj = PyTuple_GET_ITEM(obj, 0);
|
||||
|
@ -189,17 +192,19 @@ static PyObject *
|
|||
pysqlite_row_keys_impl(pysqlite_Row *self)
|
||||
/*[clinic end generated code: output=efe3dfb3af6edc07 input=7549a122827c5563]*/
|
||||
{
|
||||
PyObject* list;
|
||||
Py_ssize_t nitems, i;
|
||||
|
||||
list = PyList_New(0);
|
||||
PyObject *list = PyList_New(0);
|
||||
if (!list) {
|
||||
return NULL;
|
||||
}
|
||||
nitems = PyTuple_Size(self->description);
|
||||
if (Py_IsNone(self->description)) {
|
||||
return list;
|
||||
}
|
||||
|
||||
for (i = 0; i < nitems; i++) {
|
||||
if (PyList_Append(list, PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0)) != 0) {
|
||||
Py_ssize_t nitems = PyTuple_GET_SIZE(self->description);
|
||||
for (Py_ssize_t i = 0; i < nitems; i++) {
|
||||
PyObject *descr = PyTuple_GET_ITEM(self->description, i);
|
||||
PyObject *name = PyTuple_GET_ITEM(descr, 0);
|
||||
if (PyList_Append(list, name) < 0) {
|
||||
Py_DECREF(list);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue