Use Py_CLEAR(). Add unrelated test.

This commit is contained in:
Raymond Hettinger 2004-09-28 01:51:35 +00:00
parent b6f7fb7327
commit 6429a4727e
2 changed files with 4 additions and 1 deletions

View file

@ -23,6 +23,9 @@ def setUp(self):
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)

View file

@ -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;