mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Fix cleanup DECREF logic in builtin_filter function.
This commit is contained in:
parent
150db73c78
commit
e35b657efd
1 changed files with 6 additions and 6 deletions
|
@ -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. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue