[issue2521] ABC caches should use weak refs
Daniel Stutzbach
report at bugs.python.org
Wed Mar 31 02:36:35 CEST 2010
Daniel Stutzbach <daniel at stutzbachenterprises.com> added the comment:
You can't register an old-style class, but many ABCs support duck-typing by implementing __subclasshook__. ABCMeta caches those results and stores a reference to old-style classes, sometimes in _abc_cache and sometimes in _abc_negative_cache. It can't simply return False.
I guess that leaves two options:
1) Make old-style classes weak-referenceable and cache the results of __subclasshook__.
2) Refuse to cache old-style classes and call __subclasshook__ every time for old-style classes.
Python 2.7a4+ (trunk:79493, Mar 30 2010, 19:19:13)
>>> class old_iterable_class:
... def __iter__(self):
... pass
...
>>> import collections
>>> issubclass(old_iterable_class, collections.Iterable)
True
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2521>
_______________________________________
More information about the Python-bugs-list
mailing list