diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2024-02-17 21:18:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-17 21:18:30 (GMT) |
commit | 090dd21ab9379d6a2a6923d6cbab697355fb7165 (patch) | |
tree | 0979b9e8e3b11a590902c5745fe817943a888c33 /Lib | |
parent | aba37d451fabb44a7f478958ba117ae5b6ea54c0 (diff) | |
download | cpython-090dd21ab9379d6a2a6923d6cbab697355fb7165.zip cpython-090dd21ab9379d6a2a6923d6cbab697355fb7165.tar.gz cpython-090dd21ab9379d6a2a6923d6cbab697355fb7165.tar.bz2 |
gh-115618: Remove improper Py_XDECREFs in property methods (GH-115619)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_property.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py index 8ace9fd..ad5ab5a 100644 --- a/Lib/test/test_property.py +++ b/Lib/test/test_property.py @@ -183,6 +183,24 @@ class PropertyTests(unittest.TestCase): fake_prop.__init__('fget', 'fset', 'fdel', 'doc') self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10) + @support.refcount_test + def test_gh_115618(self): + # Py_XDECREF() was improperly called for None argument + # in property methods. + gettotalrefcount = support.get_attribute(sys, 'gettotalrefcount') + prop = property() + refs_before = gettotalrefcount() + for i in range(100): + prop = prop.getter(None) + self.assertIsNone(prop.fget) + for i in range(100): + prop = prop.setter(None) + self.assertIsNone(prop.fset) + for i in range(100): + prop = prop.deleter(None) + self.assertIsNone(prop.fdel) + self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10) + def test_property_set_name_incorrect_args(self): p = property() |