[issue9825] OrderedDict ref cycles cause memory leak
New submission from jason kirtland : Circular graphs of collections.OrderedDict are uncollectable due to the presence of OrderedDict.__del__. >>> from collections import OrderedDict >>> import gc >>> left, right = OrderedDict(), OrderedDict() >>> left['other'] = right >>> right['other'] = left >>> assert not gc.garbage >>> del left, right >>> gc.collect() 10 >>> assert not gc.garbage Traceback (most recent call last): File "", line 1, in AssertionError Not an issue in 3.1.1, have not verified with 3.1.2. -- components: Library (Lib) files: odicttest.py messages: 116036 nosy: jek priority: normal severity: normal status: open title: OrderedDict ref cycles cause memory leak type: resource usage versions: Python 2.7, Python 3.2 Added file: http://bugs.python.org/file18834/odicttest.py ___ Python tracker <http://bugs.python.org/issue9825> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9826] OrderedDict ref cycles break repr()
New submission from jason kirtland : repr of circular graphs of collections.OrderedDicts fails with 'RuntimeError: maximum recursion depth exceeded while calling a Python object'. >>> from collections import OrderedDict >>> left, right = OrderedDict(), OrderedDict() >>> left['other'] = right >>> right['other'] = left >>> left Traceback (most recent call last): File "", line 1, in ... File "lib/python2.7/collections.py", line 137, in __repr__ return '%s(%r)' % (self.__class__.__name__, self.items()) RuntimeError: maximum recursion depth exceeded in __subclasscheck__ -- components: Library (Lib) files: odictcyclerepr.py messages: 116037 nosy: jek priority: normal severity: normal status: open title: OrderedDict ref cycles break repr() type: behavior versions: Python 2.7, Python 3.1, Python 3.2 Added file: http://bugs.python.org/file18835/odictcyclerepr.py ___ Python tracker <http://bugs.python.org/issue9826> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9825] OrderedDict ref cycles cause memory leak
jason kirtland added the comment: I find the behavior surprising compared to dict and other containers, where this is not an issue and weakrefs are not required in user code. I would not be surprised, however, to have to wait for a gc.collect() to clean up my cycles like I do for regular objects. For what it's worth, the pure-python alternative linked in the docs uses neither __del__ nor weakrefs, though it is undoubtably less efficient than this implementation. And the workaround 'del OrderedDict.__del__' seems to work as well, if one is willing to wait for a gc collection. -- ___ Python tracker <http://bugs.python.org/issue9825> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3935] bisect insort C implementation ignores methods on list subclasses
New submission from jason kirtland <[EMAIL PROTECTED]>: The C implementation (only) of bisect does not invoke list subclass methods when insorting. Code like this will not trigger the assert: class Boom(list): def insert(self, index, item): assert False bisect.insort(Boom(), 123) object-derived classes are OK. -- components: Library (Lib) files: test.py messages: 73589 nosy: jek severity: normal status: open title: bisect insort C implementation ignores methods on list subclasses type: behavior versions: Python 2.5, Python 2.6 Added file: http://bugs.python.org/file11561/test.py ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3935> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2045] defaultdict subclasses segfault with a bound method set as a default_factory
New submission from jason kirtland: Python 2.5.1 (r251:54863, May 23 2007, 16:25:53) [GCC 4.1.1 20070105 (Red Hat 4.1.1-52)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from collections import defaultdict >>> class sub(defaultdict): ... def __init__(self): ... self.default_factory = self._factory ... def _factory(self): ... return [] ... >>> s = sub() >>> repr(s) Segmentation fault -- components: Library (Lib) messages: 62185 nosy: jek severity: normal status: open title: defaultdict subclasses segfault with a bound method set as a default_factory type: crash versions: Python 2.5 __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2045> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2235] __eq__ / __hash__ check doesn't take inheritance into account
New submission from jason kirtland: In 2.6a, seems like the __hash__ implementation and __eq__ must be defined together, in the same class. See also #1549. Ensuring that a __hash__ implementation isn't being pulled from a builtin type is probably a sufficient check...? >>> class Base(object): ... def __init__(self, name): ... self.name = name ... def __eq__(self, other): ... return self.name == other.name ... def __hash__(self): ... return hash(self.name) ... >>> class Extended(Base): ... def __eq__(self, other): ... print "trace: __eq__ called" ... return Base.__eq__(self, other) ... >>> hash(Base('b1')) 603887253 >>> hash(Extended('e1')) Traceback (most recent call last): File "", line 1, in TypeError: unhashable type: 'Extended' -- components: Interpreter Core messages: 63258 nosy: jek severity: normal status: open title: __eq__ / __hash__ check doesn't take inheritance into account type: crash versions: Python 2.6 __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2235> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com