fresh=['_elementtree', 'xml.etree'])
+@unittest.skipUnless(cET, 'requires _elementtree')
class MiscTests(unittest.TestCase):
# Issue #8651.
@support.bigmemtest(size=support._2G + 100, memuse=1, dry_run=False)
del element.attrib
self.assertEqual(element.attrib, {'A': 'B', 'C': 'D'})
+ def test_trashcan(self):
+ # If this test fails, it will most likely die via segfault.
+ e = root = cET.Element('root')
+ for i in range(200000):
+ e = cET.SubElement(e, 'x')
+ del e
+ del root
+ support.gc_collect()
+
@unittest.skipUnless(cET, 'requires _elementtree')
class TestAliasWorking(unittest.TestCase):
Library
-------
+- Issue #28871: Fixed a crash when deallocate deep ElementTree.
+
- Issue #19542: Fix bugs in WeakValueDictionary.setdefault() and
WeakValueDictionary.pop() when a GC collection happens in another
thread.
element_dealloc(ElementObject* self)
{
PyObject_GC_UnTrack(self);
+ Py_TRASHCAN_SAFE_BEGIN(self)
if (self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
RELEASE(sizeof(ElementObject), "destroy element");
Py_TYPE(self)->tp_free((PyObject *)self);
+ Py_TRASHCAN_SAFE_END(self)
}
/* -------------------------------------------------------------------- */