[Python-checkins] python/nondist/sandbox/setobj setobject.c, 1.20,
1.21 test_set.py, 1.20, 1.21
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sat Nov 15 17:54:05 EST 2003
Update of /cvsroot/python/python/nondist/sandbox/setobj
In directory sc8-pr-cvs1:/tmp/cvs-serv24218
Modified Files:
setobject.c test_set.py
Log Message:
Make sure the single argument methods also check for unhashable arguments.
Index: setobject.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setobj/setobject.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** setobject.c 15 Nov 2003 22:36:20 -0000 1.20
--- setobject.c 15 Nov 2003 22:54:03 -0000 1.21
***************
*** 760,764 ****
{
if (PyDict_DelItem(so->data, item) == -1)
! PyErr_Clear();
Py_INCREF(Py_None);
return Py_None;
--- 760,767 ----
{
if (PyDict_DelItem(so->data, item) == -1)
! if (PyErr_ExceptionMatches(PyExc_KeyError))
! PyErr_Clear();
! else
! return NULL;
Py_INCREF(Py_None);
return Py_None;
Index: test_set.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/setobj/test_set.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** test_set.py 15 Nov 2003 22:36:20 -0000 1.20
--- test_set.py 15 Nov 2003 22:54:03 -0000 1.21
***************
*** 40,43 ****
--- 40,44 ----
for c in self.letters:
self.assertEqual(c in self.s, c in self.d)
+ self.assertRaises(TypeError, self.s.__contains__, [[]])
def test_copy(self):
***************
*** 167,170 ****
--- 168,172 ----
self.s.add('Q')
self.assert_('Q' in self.s)
+ self.assertRaises(TypeError, self.s.add, [])
def test_remove(self):
***************
*** 172,175 ****
--- 174,178 ----
self.assert_('a' not in self.s)
self.assertRaises(KeyError, self.s.remove, 'Q')
+ self.assertRaises(TypeError, self.s.remove, [])
def test_discard(self):
***************
*** 177,180 ****
--- 180,184 ----
self.assert_('a' not in self.s)
self.s.discard('Q')
+ self.assertRaises(TypeError, self.s.discard, [])
def test_pop(self):
More information about the Python-checkins
mailing list