Skip to content

Commit b1a1a59

Browse files
committed
[Python] Clear TList in tseqcollection_itemaccess.py:test_delitem
Clear the TList at the end of the `test_delitem` unit test in tseqcollection_itemaccess.py to make sure the contained list elements are still alive when the list is cleared. Otherwise, the elements might be deleted before the containing list, depending on the order or garbage collection.
1 parent 5d902d8 commit b1a1a59

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

bindings/pyroot/pythonizations/test/tseqcollection_itemaccess.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ def test_delitem(self):
239239
with self.assertRaises(TypeError):
240240
del sc[1.0]
241241

242+
# Clear before the added element might be garbage collected,
243+
# to avoid dangling pointer access.
244+
sc.Clear()
245+
242246
def test_delitem_slice(self):
243247
# Delete all items
244248
sc1 = self.create_tseqcollection()

0 commit comments

Comments
 (0)