From 6429a4727e4bb8bcb0d3deefaefe195e63e6bb6e Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Tue, 28 Sep 2004 01:51:35 +0000 Subject: Use Py_CLEAR(). Add unrelated test. --- Lib/test/test_set.py | 3 +++ Objects/setobject.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index 01dded6..aab0c57 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -23,6 +23,9 @@ class TestJointOps(unittest.TestCase): self.s = self.thetype(word) self.d = dict.fromkeys(word) + def test_new_or_init(self): + self.assertRaises(TypeError, self.thetype, [], 2) + def test_uniquification(self): actual = sorted(self.s) expected = sorted(self.d) diff --git a/Objects/setobject.c b/Objects/setobject.c index 289d5d3..d57217c 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -105,7 +105,7 @@ frozenset_dict_wrapper(PyObject *d) w = (PySetObject *)make_new_set(&PyFrozenSet_Type, NULL); if (w == NULL) return NULL; - Py_DECREF(w->data); + Py_CLEAR(w->data); Py_INCREF(d); w->data = d; return (PyObject *)w; -- cgit v0.12