[Python-bugs-list] [ python-Bugs-485781 ] get_refer{ent,rer}s() doesn't use `is'

noreply@sourceforge.net noreply@sourceforge.net
Wed, 28 Nov 2001 07:52:19 -0800


Bugs item #485781, was opened at 2001-11-26 13:16
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=485781&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 7
Submitted By: Zooko Ozoko (zooko)
Assigned to: Martin v. Löwis (loewis)
Summary: get_refer{ent,rer}s() doesn't use `is'

Initial Comment:
in Python 2.2b2 as packaged by debian,
gc.get_referents() seems to be using equality testing
rather than identity testing to find referents.  Example:

>>> l = [0,3,2,{},]
>>> gc.get_referents({})
[Type help() for interactive help, or help(object) for
help about object., [0, 3, 2, {}]]


The list should not have appeared in the result.



----------------------------------------------------------------------

>Comment By: Zooko Ozoko (zooko)
Date: 2001-11-28 07:52

Message:
Logged In: YES 
user_id=52562

Whoops, although it survived an overnight run of
continuously doing `get_referrers({})' (which formerly would
have triggered a seg fault), it did not survive the
following interactive code:

>>> for ref in refs[:]:
...  for k, v in locals().items():
...   if (ref is k) or (ref is v):
...    refs.remove(ref)
...

That got a segfault.  `refs' was a list of objects (namely,
all objects in the current runtime that held a reference to
an empty dict.


----------------------------------------------------------------------

Comment By: Zooko Ozoko (zooko)
Date: 2001-11-28 06:39

Message:
Logged In: YES 
user_id=52562

Yep!  That patch fixes the problem with getting answers I
didn't want *and* it fixes the seg faults!

Now I'm making faster progress on diagnosing memory usage in
Mojo Nation.  Whoo-hoo!



----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2001-11-26 23:22

Message:
Logged In: YES 
user_id=21627

Please try the attached patch (or report back if you cannot).

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=485781&group_id=5470