This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Restore GC support to set objects
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: barry, jimjjewett, rhettinger
Priority: high Keywords: patch

Created on 2005-05-11 17:16 by barry, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
set-patch.txt barry, 2005-05-11 17:16
set-patch2.txt barry, 2005-05-11 19:58
cycle.py barry, 2005-05-11 19:59
Messages (6)
msg48324 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2005-05-11 17:16
Contrary to what the log message for setobject.c 1.26
implies, built-in sets can indeed participate in
cycles, so they must support GC.  This patch restores
GC support to built-in sets for Python 2.4.  It should
be ported to Python 2.5.
msg48325 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2005-05-11 19:58
Logged In: YES 
user_id=12800

Actually, use set-patch2.txt because I don't believe you
need to clear so->data in set_tp_clear().
msg48326 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2005-05-11 19:59
Logged In: YES 
user_id=12800

cycle.py demonstrates the need for this patch
msg48327 - (view) Author: Jim Jewett (jimjjewett) Date: 2005-05-11 22:20
Logged In: YES 
user_id=764593

Clarification:  cycle.py *as posted* does not demonstrate the 
problem, but if you uncomment the __del__ method in class 
foo, you will get uncollectable garbage.
msg48328 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2005-05-11 22:41
Logged In: YES 
user_id=12800

Even without the __del__() method, notice how the second
gc.collect() prints 0.  With the patch it prints 4.
msg48329 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2005-06-18 20:59
Logged In: YES 
user_id=80475

Okay, fixed.
Kept the PyDict_Clear since that is what is done in
dictobject.c.
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 41970
2005-05-11 17:16:30barrycreate