mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +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
|
|
@ -1559,6 +1559,15 @@ order (MRO) for bases """
|
|||
del cm.x
|
||||
self.assertNotHasAttr(cm, "x")
|
||||
|
||||
@support.refcount_test
|
||||
def test_refleaks_in_classmethod___init__(self):
|
||||
gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount')
|
||||
cm = classmethod(None)
|
||||
refs_before = gettotalrefcount()
|
||||
for i in range(100):
|
||||
cm.__init__(None)
|
||||
self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10)
|
||||
|
||||
@support.impl_detail("the module 'xxsubtype' is internal")
|
||||
def test_classmethods_in_c(self):
|
||||
# Testing C-based class methods...
|
||||
|
|
@ -1614,6 +1623,15 @@ order (MRO) for bases """
|
|||
del sm.x
|
||||
self.assertNotHasAttr(sm, "x")
|
||||
|
||||
@support.refcount_test
|
||||
def test_refleaks_in_staticmethod___init__(self):
|
||||
gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount')
|
||||
sm = staticmethod(None)
|
||||
refs_before = gettotalrefcount()
|
||||
for i in range(100):
|
||||
sm.__init__(None)
|
||||
self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10)
|
||||
|
||||
@support.impl_detail("the module 'xxsubtype' is internal")
|
||||
def test_staticmethods_in_c(self):
|
||||
# Testing C-based static methods...
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue