diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2014-08-28 14:19:25 +0200 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2014-08-28 14:19:25 +0200 |
commit | 11589fcf5b28101ec7b8de286ad0133a4894f83c (patch) | |
tree | 5b337001a289ac7da00e633cba94521d76a04d3b /src/lxml/tests/test_etree.py | |
parent | d4f06ac0703961cc4a88504369aff5a5465b7561 (diff) | |
download | python-lxml-11589fcf5b28101ec7b8de286ad0133a4894f83c.tar.gz |
fix crash when deallocating sibling Element proxies that do not have a parent
Diffstat (limited to 'src/lxml/tests/test_etree.py')
-rw-r--r-- | src/lxml/tests/test_etree.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/lxml/tests/test_etree.py b/src/lxml/tests/test_etree.py index 41d6571f..132e2ce9 100644 --- a/src/lxml/tests/test_etree.py +++ b/src/lxml/tests/test_etree.py @@ -3557,6 +3557,37 @@ class ETreeOnlyTestCase(HelperTestCase): gc.collect() # not really testing anything here, but it shouldn't crash + def test_proxy_collect_siblings(self): + root = etree.Element('parent') + c1 = etree.SubElement(root, 'child1') + c2 = etree.SubElement(root, 'child2') + + root.remove(c1) + root.remove(c2) + c1.addnext(c2) + del c1 + # trigger deallocation attempt of c1 + c2.getprevious() + # make sure it wasn't deallocated + self.assertEqual('child1', c2.getprevious().tag) + + def test_proxy_collect_siblings_text(self): + root = etree.Element('parent') + c1 = etree.SubElement(root, 'child1') + c2 = etree.SubElement(root, 'child2') + + root.remove(c1) + root.remove(c2) + c1.addnext(c2) + c1.tail = 'abc' + c2.tail = 'xyz' + del c1 + # trigger deallocation attempt of c1 + c2.getprevious() + # make sure it wasn't deallocated + self.assertEqual('child1', c2.getprevious().tag) + self.assertEqual('abc', c2.getprevious().tail) + # helper methods def _writeElement(self, element, encoding='us-ascii', compression=0): |