cpython: 957091874ea0 (original) (raw)
Mercurial > cpython
changeset 105764:957091874ea0 3.5
Issue #28871: Fixed a crash when deallocate deep ElementTree. [#28871]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Wed, 21 Dec 2016 12:32:56 +0200 |
parents | 2f004cc84153 |
children | 9b2e71492b53 eb8667196f93 |
files | Lib/test/test_xml_etree_c.py Misc/NEWS Modules/_elementtree.c |
diffstat | 3 files changed, 14 insertions(+), 0 deletions(-)[+] [-] Lib/test/test_xml_etree_c.py 10 Misc/NEWS 2 Modules/_elementtree.c 2 |
line wrap: on
line diff
--- a/Lib/test/test_xml_etree_c.py +++ b/Lib/test/test_xml_etree_c.py @@ -11,6 +11,7 @@ cET_alias = import_fresh_module('xml.etr 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) @@ -54,6 +55,15 @@ class MiscTests(unittest.TestCase): 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.[](#l1.16)
e = root = cET.Element('root')[](#l1.17)
for i in range(200000):[](#l1.18)
e = cET.SubElement(e, 'x')[](#l1.19)
del e[](#l1.20)
del root[](#l1.21)
support.gc_collect()[](#l1.22)
+ @unittest.skipUnless(cET, 'requires _elementtree') class TestAliasWorking(unittest.TestCase):
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -138,6 +138,8 @@ Core and Builtins 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.
--- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -652,6 +652,7 @@ static void element_dealloc(ElementObject* self) { PyObject_GC_UnTrack(self);
if (self->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject ) self); @@ -662,6 +663,7 @@ element_dealloc(ElementObject self) RELEASE(sizeof(ElementObject), "destroy element"); Py_TYPE(self)->tp_free((PyObject *)self);
} /* -------------------------------------------------------------------- */