summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2005-07-19 22:20:44 (GMT)
committerGeorg Brandl <georg@python.org>2005-07-19 22:20:44 (GMT)
commit3ccd18e3df7e0c5152eda6289a4f859252053dd2 (patch)
tree235f9cad68283230826de93c4fbb04367e2755f7 /Python/bltinmodule.c
parenteb0b029a338cb401a371f19727f13113719fffaa (diff)
downloadcpython-3ccd18e3df7e0c5152eda6289a4f859252053dd2.zip
cpython-3ccd18e3df7e0c5152eda6289a4f859252053dd2.tar.gz
cpython-3ccd18e3df7e0c5152eda6289a4f859252053dd2.tar.bz2
Backport: fix cleanup DECREF logic in builtin_filter function.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 6fbe799..8dd3f1c 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -147,10 +147,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);
@@ -159,11 +164,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. */