[ python-Bugs-980092 ] tp_subclasses grow without bounds
SourceForge.net
noreply at sourceforge.net
Tue Jun 29 14:55:26 EDT 2004
Bugs item #980092, was opened at 2004-06-26 01:54
Message generated for change (Comment added) made by mwh
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=980092&group_id=5470
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Eric Huss (ehuss)
Assigned to: Nobody/Anonymous (nobody)
Summary: tp_subclasses grow without bounds
Initial Comment:
Python 2.3.4
When heap allocated type objects are created, they will
be added to their base class's tp_subclasses list as a
weak reference. If, for example, your base type is
PyBaseObject_Type, then the tp_subclasses list for the
base object type will grow for each new object.
Unfortunately remove_subclass is never called. If your
newly create type objects are deleted, then you will end
up with a bunch of weak reference objects in the
tp_subclasses list that do not reference anything.
Perhaps remove_subclass should be called inside
type_dealloc? Or, better yet, tp_subclasses should be a
Weak Set. I'm not certain what's the best solution.
----------------------------------------------------------------------
>Comment By: Michael Hudson (mwh)
Date: 2004-06-29 19:55
Message:
Logged In: YES
user_id=6656
It's not quite as bad as you might think, because
add_subclass will stomp on a dead reference if it finds one.
So the length of tp_subclasses is bounded by the number of
bases that exist at any one time, which doesn't seem too bad
to me. Still, it would seem cleaner to do the removal at
type_dealloc time...
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=980092&group_id=5470
More information about the Python-bugs-list
mailing list