]> granicus.if.org Git - python/commitdiff
PyList_Reverse(): This was leaking a reference to Py_None on every call.
authorTim Peters <tim.peters@gmail.com>
Thu, 8 Aug 2002 01:06:39 +0000 (01:06 +0000)
committerTim Peters <tim.peters@gmail.com>
Thu, 8 Aug 2002 01:06:39 +0000 (01:06 +0000)
I believe I introduced this bug when I refactored the reversal code so
that the mergesort could use it too.  It's not a problem on the 2.2 branch.

Objects/listobject.c

index e2b9b2b7c104bcaae862cfa8c96d4e5ad75241db..7fad905060bc8cf4625863ef231f102ec7df9051 100644 (file)
@@ -1718,11 +1718,14 @@ listreverse(PyListObject *self)
 int
 PyList_Reverse(PyObject *v)
 {
+       PyListObject *self = (PyListObject *)v;
+
        if (v == NULL || !PyList_Check(v)) {
                PyErr_BadInternalCall();
                return -1;
        }
-       listreverse((PyListObject *)v);
+       if (self->ob_size > 1)
+               reverse_slice(self->ob_item, self->ob_item + self->ob_size);
        return 0;
 }