diff options
| author | Oren Milman <orenmn@gmail.com> | 2018-02-13 12:28:33 +0200 |
|---|---|---|
| committer | INADA Naoki <methane@users.noreply.github.com> | 2018-02-13 19:28:33 +0900 |
| commit | d019bc8319ea35e93bf4baa38098ff1b57cd3ee5 (patch) | |
| tree | d9b927eba02059f8be8465d35b6969254b172b8e /Lib/test/test_descr.py | |
| parent | aec7532ed3ccbd29d3429a3f375e25f956c44003 (diff) | |
| download | cpython-git-d019bc8319ea35e93bf4baa38098ff1b57cd3ee5.tar.gz | |
bpo-31787: Prevent refleaks when calling __init__() more than once (GH-3995)
Diffstat (limited to 'Lib/test/test_descr.py')
| -rw-r--r-- | Lib/test/test_descr.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index d24d005ccf..0e7728ebf2 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -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... |
