[issue2521] ABC caches should use weak refs
Amaury Forgeot d'Arc
report at bugs.python.org
Mon Mar 31 17:12:30 CEST 2008
New submission from Amaury Forgeot d'Arc <amauryfa at gmail.com>:
The following function seems to 8 references each time it is run:
import io, gc
def f():
class C: pass
c=C()
assert isinstance(c, io.StringIO) is False
gc.collect();gc.collect();gc.collect()
This is because io.StringIO._abc_negative_cache contains a strong
reference to each "class C", as soon as isinstance() is called. These
are never released.
Python3.0 does use WeakSet for these caches, and does not leak.
This is the (deep) reason why test_io.IOTest.test_destructor() leaks in
the following report:
http://mail.python.org/pipermail/python-checkins/2008-March/067918.html
(The test derives from io.FileIO, and it is the call to the base class'
method which calls isinstance() and put the class in the cache)
----------
components: Interpreter Core
keywords: 26backport
messages: 64784
nosy: amaury.forgeotdarc
severity: normal
status: open
title: ABC caches should use weak refs
versions: Python 2.6
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2521>
__________________________________
More information about the Python-bugs-list
mailing list