summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2005-07-19 22:20:20 (GMT)
committerGeorg Brandl <georg@python.org>2005-07-19 22:20:20 (GMT)
commite35b657efd1b2eae89497233f6494f8323d5ad1e (patch)
tree271682e40ffb9e9480d9a59b93ec74b987667b75
parent150db73c78daf5d8966ef5a5e700f87c28a02d80 (diff)
downloadcpython-e35b657efd1b2eae89497233f6494f8323d5ad1e.zip
cpython-e35b657efd1b2eae89497233f6494f8323d5ad1e.tar.gz
cpython-e35b657efd1b2eae89497233f6494f8323d5ad1e.tar.bz2
Fix cleanup DECREF logic in builtin_filter function.
-rw-r--r--Python/bltinmodule.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 145e946..f63e27a 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -210,10 +210,15 @@ builtin_filter(PyObject *self, PyObject *args)
if (PyTuple_Check(seq))
return filtertuple(func, seq);
+ /* Pre-allocate argument list tuple. */
+ arg = PyTuple_New(1);
+ if (arg == NULL)
+ return NULL;
+
/* Get iterator. */
it = PyObject_GetIter(seq);
if (it == NULL)
- return NULL;
+ goto Fail_arg;
/* Guess a result list size. */
len = PyObject_Size(seq);
@@ -222,11 +227,6 @@ builtin_filter(PyObject *self, PyObject *args)
len = 8; /* arbitrary */
}
- /* Pre-allocate argument list tuple. */
- arg = PyTuple_New(1);
- if (arg == NULL)
- goto Fail_arg;
-
/* Get a result list. */
if (PyList_Check(seq) && seq->ob_refcnt == 1) {
/* Eww - can modify the list in-place. */