mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
bpo-31787: Prevent refleaks when calling __init__() more than once (GH-3995)
This commit is contained in:
parent
aec7532ed3
commit
d019bc8319
13 changed files with 105 additions and 19 deletions
|
@ -162,6 +162,15 @@ class HashLibTestCase(unittest.TestCase):
|
|||
constructors = self.constructors_to_test.values()
|
||||
return itertools.chain.from_iterable(constructors)
|
||||
|
||||
@support.refcount_test
|
||||
def test_refleaks_in_hash___init__(self):
|
||||
gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount')
|
||||
sha1_hash = c_hashlib.new('sha1')
|
||||
refs_before = gettotalrefcount()
|
||||
for i in range(100):
|
||||
sha1_hash.__init__('sha1')
|
||||
self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10)
|
||||
|
||||
def test_hash_array(self):
|
||||
a = array.array("b", range(10))
|
||||
for cons in self.hash_constructors:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue