[Python-bugs-list] [ python-Bugs-425836 ] Reference leak in filter()
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 21 May 2001 01:08:34 -0700
Bugs item #425836, was updated on 2001-05-21 00:37
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=425836&group_id=5470
Category: Python Interpreter Core
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Mark Hammond (mhammond)
Assigned to: Tim Peters (tim_one)
Summary: Reference leak in filter()
Initial Comment:
I appear to have struck a reference leak in filter:
>>> l=range(10)
[5552 refs]
>>> l2=filter(lambda m:m, l)
[5571 refs]
>>> l2=filter(lambda m:m, l)
[5574 refs]
etc - always dropping 3 references.
The following patch fixes it:
Index: bltinmodule.c
=======================================================
============
RCS
file: /cvsroot/python/python/dist/src/Python/bltinmodul
e.c,v
retrieving revision 2.207
diff -c -r2.207 bltinmodule.c
*** bltinmodule.c 2001/05/14 12:17:34 2.207
--- bltinmodule.c 2001/05/21 07:37:07
***************
*** 264,269 ****
--- 264,270 ----
if (j < len && PyList_SetSlice(result, j, len,
NULL) < 0)
goto Fail_result_it;
+ Py_DECREF(it);
return result;
Fail_result_it:
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2001-05-21 01:08
Message:
Logged In: YES
user_id=31435
So don't use filter <wink>.
Oh, all right, it's a bug. Thanks for enduring the pain!
Checked in as Python/bltinmodule.c, new revision: 2.208.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=425836&group_id=5470