summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2024-02-17 21:18:30 (GMT)
committerGitHub <noreply@github.com>2024-02-17 21:18:30 (GMT)
commit090dd21ab9379d6a2a6923d6cbab697355fb7165 (patch)
tree0979b9e8e3b11a590902c5745fe817943a888c33 /Lib
parentaba37d451fabb44a7f478958ba117ae5b6ea54c0 (diff)
downloadcpython-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.py18
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()