Message304145
The following code results in refleaks:
import sys
import _elementtree
builder = _elementtree.TreeBuilder()
parser = _elementtree.XMLParser(target=builder)
refcount_before = sys.gettotalrefcount()
parser.__init__(target=builder)
print(sys.gettotalrefcount() - refcount_before) # should be close to 0
This is because _elementtree_XMLParser___init___impl()
(in Modules/_elementtree.c) doesn't decref before assigning to fields of
`self`.
The following code also results in refleaks:
import sys
import _elementtree
elem = _elementtree.Element(42)
elem.__setstate__({'tag': 42, '_children': list(range(1000))})
refcount_before = sys.gettotalrefcount()
elem.__setstate__({'tag': 42, '_children': []})
print(sys.gettotalrefcount() - refcount_before) # should be close to -1000
This is because element_setstate_from_attributes() doesn't decref the old
children before storing the new children.
I would open a PR to fix this soon. |
|
Date |
User |
Action |
Args |
2017-10-11 14:53:40 | Oren Milman | set | recipients:
+ Oren Milman |
2017-10-11 14:53:39 | Oren Milman | set | messageid: <1507733619.97.0.213398074469.issue31758@psf.upfronthosting.co.za> |
2017-10-11 14:53:39 | Oren Milman | link | issue31758 messages |
2017-10-11 14:53:39 | Oren Milman | create | |
|