This fixes SF bug #132008, reported by Warren J. Hack.
The copyright for this patch (and this patch only) belongs to CNRI, as
part of the (yet to be issued) 1.6.1 release.
This is now checked into the HEAD branch. Tim will check in a test
case to check for this specific bug, and an assertion in
PyArgs_ParseTuple() to catch similar bugs in the future.
return 0;
}
-static PyObject *
-listreverse(PyListObject *self, PyObject *args)
+static void
+_listreverse(PyListObject *self)
{
register PyObject **p, **q;
register PyObject *tmp;
- if (!PyArg_ParseTuple(args, ":reverse"))
- return NULL;
-
if (self->ob_size > 1) {
for (p = self->ob_item, q = self->ob_item + self->ob_size - 1;
- p < q; p++, q--) {
+ p < q;
+ p++, q--)
+ {
tmp = *p;
*p = *q;
*q = tmp;
}
}
-
+}
+
+static PyObject *
+listreverse(PyListObject *self, PyObject *args)
+{
+ if (!PyArg_ParseTuple(args, ":reverse"))
+ return NULL;
+ _listreverse(self);
Py_INCREF(Py_None);
return Py_None;
}
PyErr_BadInternalCall();
return -1;
}
- v = listreverse((PyListObject *)v, (PyObject *)NULL);
- if (v == NULL)
- return -1;
- Py_DECREF(v);
+ _listreverse((PyListObject *)v);
return 0;
}