"cannot add more objects to list");
return -1;
}
-
+
if (list_resize(self, n+1) == -1)
return -1;
}
if (num_free_lists < MAXFREELISTS && PyList_CheckExact(op))
free_lists[num_free_lists++] = op;
- else
- op->ob_type->tp_free((PyObject *)op);
+ else
+ op->ob_type->tp_free((PyObject *)op);
Py_TRASHCAN_SAFE_END(op)
}
memcpy(p, &item[ilow], (ihigh - ilow)*sizeof(PyObject *));
p += ihigh - ilow;
if (d < 0) {
- memmove(&item[ihigh+d], &item[ihigh],
+ memmove(&item[ihigh+d], &item[ihigh],
(a->ob_size - ihigh)*sizeof(PyObject *));
list_resize(a, a->ob_size + d);
item = a->ob_item;
return (PyObject *)self;
}
- if (list_resize(self, size*n) == -1)
+ if (list_resize(self, size*n) == -1)
return NULL;
p = size;
PyObject *(*iternext)(PyObject *);
/* Special cases:
- 1) lists and tuples which can use PySequence_Fast ops
- 2) extending self to self requires making a copy first
+ 1) lists and tuples which can use PySequence_Fast ops
+ 2) extending self to self requires making a copy first
*/
if (PyList_CheckExact(b) || PyTuple_CheckExact(b) || (PyObject *)self == b) {
PyObject **src, **dest;
/* Special wrapper to support stable sorting using the decorate-sort-undecorate
pattern. Holds a key which is used for comparisions and the original record
- which is returned during the undecorate phase. By exposing only the key
- during comparisons, the underlying sort stability characteristics are left
- unchanged. Also, if a custom comparison function is used, it will only see
+ which is returned during the undecorate phase. By exposing only the key
+ during comparisons, the underlying sort stability characteristics are left
+ unchanged. Also, if a custom comparison function is used, it will only see
the key instead of a full record. */
typedef struct {
sortwrapper_richcompare(sortwrapperobject *a, sortwrapperobject *b, int op)
{
if (!PyObject_TypeCheck(b, &sortwrapper_type)) {
- PyErr_SetString(PyExc_TypeError,
+ PyErr_SetString(PyExc_TypeError,
"expected a sortwrapperobject");
return NULL;
}
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT |
+ Py_TPFLAGS_DEFAULT |
Py_TPFLAGS_HAVE_RICHCOMPARE, /* tp_flags */
sortwrapper_doc, /* tp_doc */
0, /* tp_traverse */
build_sortwrapper(PyObject *key, PyObject *value)
{
sortwrapperobject *so;
-
+
so = PyObject_New(sortwrapperobject, &sortwrapper_type);
if (so == NULL)
return NULL;
PyObject *value;
if (!PyObject_TypeCheck(so, &sortwrapper_type)) {
- PyErr_SetString(PyExc_TypeError,
+ PyErr_SetString(PyExc_TypeError,
"expected a sortwrapperobject");
return NULL;
}
return NULL;
if (!PyObject_TypeCheck(x, &sortwrapper_type) ||
!PyObject_TypeCheck(y, &sortwrapper_type)) {
- PyErr_SetString(PyExc_TypeError,
+ PyErr_SetString(PyExc_TypeError,
"expected a sortwrapperobject");
return NULL;
}
build_cmpwrapper(PyObject *cmpfunc)
{
cmpwrapperobject *co;
-
+
co = PyObject_New(cmpwrapperobject, &cmpwrapper_type);
if (co == NULL)
return NULL;
if (keyfunc != NULL) {
for (i=0 ; i < saved_ob_size ; i++) {
value = saved_ob_item[i];
- key = PyObject_CallFunctionObjArgs(keyfunc, value,
+ key = PyObject_CallFunctionObjArgs(keyfunc, value,
NULL);
if (key == NULL) {
for (i=i-1 ; i>=0 ; i--) {
saved_ob_item[i] = value;
Py_DECREF(kvpair);
}
- if (self->ob_item != empty_ob_item
+ if (self->ob_item != empty_ob_item
|| self->ob_size) {
/* If the list changed *as well* we
have two errors. We let the first
self, 0, self->ob_size,
(PyObject *)NULL);
}
-
+
goto dsu_fail;
}
kvpair = build_sortwrapper(key, value);
lim = self->ob_size - cur - 1;
}
- memmove(self->ob_item + cur - i,
+ memmove(self->ob_item + cur - i,
self->ob_item + cur + 1,
lim * sizeof(PyObject *));
}
PyList_GET_SIZE(value));
}
else {
- seq = PySequence_Fast(value,
+ seq = PySequence_Fast(value,
"must assign iterable to extended slice");
if (!seq)
return -1;