gh-140517: fix leak in map_next in strict mode (#140543)

This commit is contained in:
Mikhail Efimov 2025-10-24 18:59:16 +03:00 committed by GitHub
parent 95e5d59630
commit be5af997f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 41 additions and 19 deletions

View file

@ -1385,6 +1385,22 @@ def test_map_strict(self):
self.assertRaises(ValueError, tuple,
map(pack, (1, 2), (1, 2), 'abc', strict=True))
# gh-140517: Testing refleaks with mortal objects.
t1 = (None, object())
t2 = (object(), object())
t3 = (object(),)
self.assertRaises(ValueError, tuple,
map(pack, t1, 'a', strict=True))
self.assertRaises(ValueError, tuple,
map(pack, t1, t2, 'a', strict=True))
self.assertRaises(ValueError, tuple,
map(pack, t1, t2, t3, strict=True))
self.assertRaises(ValueError, tuple,
map(pack, 'a', t1, strict=True))
self.assertRaises(ValueError, tuple,
map(pack, 'a', t2, t3, strict=True))
def test_map_strict_iterators(self):
x = iter(range(5))
y = [0]