diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-21 10:36:29 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-21 10:36:29 (GMT) |
commit | 47bdc40352b06cc28ed91c988dbd65bb3b298471 (patch) | |
tree | 590a2572c3292da1a3fd3cb595555fa5600cabc3 | |
parent | b211068f5c8e2535ab2dd7f4c43325bbf5b30fad (diff) | |
parent | 690e81f63f5cac9ca6fdb0ff90f1c43e98c9e510 (diff) | |
download | cpython-47bdc40352b06cc28ed91c988dbd65bb3b298471.zip cpython-47bdc40352b06cc28ed91c988dbd65bb3b298471.tar.gz cpython-47bdc40352b06cc28ed91c988dbd65bb3b298471.tar.bz2 |
Merge from 3.6.
-rw-r--r-- | Lib/test/test_xml_etree_c.py | 10 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Modules/_elementtree.c | 2 |
3 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py index 87f3f27..7c60699 100644 --- 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.etree.cElementTree', 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. + 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): @@ -205,6 +205,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. diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index 9e6f63b..5d63913 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -626,6 +626,7 @@ static void element_dealloc(ElementObject* self) { PyObject_GC_UnTrack(self); + Py_TRASHCAN_SAFE_BEGIN(self) if (self->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) self); @@ -636,6 +637,7 @@ element_dealloc(ElementObject* self) RELEASE(sizeof(ElementObject), "destroy element"); Py_TYPE(self)->tp_free((PyObject *)self); + Py_TRASHCAN_SAFE_END(self) } /* -------------------------------------------------------------------- */ |