diff options
author | Oren Milman <orenmn@gmail.com> | 2018-02-13 10:28:33 (GMT) |
---|---|---|
committer | INADA Naoki <methane@users.noreply.github.com> | 2018-02-13 10:28:33 (GMT) |
commit | d019bc8319ea35e93bf4baa38098ff1b57cd3ee5 (patch) | |
tree | d9b927eba02059f8be8465d35b6969254b172b8e /Lib/test/test_property.py | |
parent | aec7532ed3ccbd29d3429a3f375e25f956c44003 (diff) | |
download | cpython-d019bc8319ea35e93bf4baa38098ff1b57cd3ee5.zip cpython-d019bc8319ea35e93bf4baa38098ff1b57cd3ee5.tar.gz cpython-d019bc8319ea35e93bf4baa38098ff1b57cd3ee5.tar.bz2 |
bpo-31787: Prevent refleaks when calling __init__() more than once (GH-3995)
Diffstat (limited to 'Lib/test/test_property.py')
-rw-r--r-- | Lib/test/test_property.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py index 26b7d52..f6f8f5e 100644 --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -3,6 +3,7 @@ import sys import unittest +from test import support class PropertyBase(Exception): pass @@ -173,6 +174,16 @@ class PropertyTests(unittest.TestCase): sub.__class__.spam.__doc__ = 'Spam' self.assertEqual(sub.__class__.spam.__doc__, 'Spam') + @support.refcount_test + def test_refleaks_in___init__(self): + gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount') + fake_prop = property('fget', 'fset', 'fdel', 'doc') + refs_before = gettotalrefcount() + for i in range(100): + fake_prop.__init__('fget', 'fset', 'fdel', 'doc') + self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10) + + # Issue 5890: subclasses of property do not preserve method __doc__ strings class PropertySub(property): """This is a subclass of property""" |