File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -210,10 +210,15 @@ builtin_filter(PyObject *self, PyObject *args)
210210 if (PyTuple_Check (seq ))
211211 return filtertuple (func , seq );
212212
213+ /* Pre-allocate argument list tuple. */
214+ arg = PyTuple_New (1 );
215+ if (arg == NULL )
216+ return NULL ;
217+
213218 /* Get iterator. */
214219 it = PyObject_GetIter (seq );
215220 if (it == NULL )
216- return NULL ;
221+ goto Fail_arg ;
217222
218223 /* Guess a result list size. */
219224 len = PyObject_Size (seq );
@@ -222,11 +227,6 @@ builtin_filter(PyObject *self, PyObject *args)
222227 len = 8 ; /* arbitrary */
223228 }
224229
225- /* Pre-allocate argument list tuple. */
226- arg = PyTuple_New (1 );
227- if (arg == NULL )
228- goto Fail_arg ;
229-
230230 /* Get a result list. */
231231 if (PyList_Check (seq ) && seq -> ob_refcnt == 1 ) {
232232 /* Eww - can modify the list in-place. */
You can’t perform that action at this time.
0 commit comments