Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_struct.py @ 62847:f6266c459156
don't ignore exceptions from PyObject_IsTrue
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Wed, 07 Jul 2010 18:54:59 +0000 |
| parents | 74b2cbda9bda |
| children | 382dcb0c6073 |
line wrap: on
line diff
--- a/Lib/test/test_struct.py Wed Jul 07 18:51:43 2010 +0000 +++ b/Lib/test/test_struct.py Wed Jul 07 18:54:59 2010 +0000 @@ -475,6 +475,9 @@ self.assertEqual(value, 0x12345678) def test_bool(self): + class ExplodingBool(object): + def __bool__(self): + raise IOError for prefix in tuple("<>!=")+('',): false = (), [], [], '', 0 true = [1], 'test', 5, -1, 0xffffffff+1, 0xffffffff/2 @@ -503,6 +506,9 @@ self.assertFalse(prefix, msg='encoded bool is not one byte: %r' %packed) + self.assertRaises(IOError, struct.pack, prefix + '?', + ExplodingBool()) + for c in [b'\x01', b'\x7f', b'\xff', b'\x0f', b'\xf0']: self.assertTrue(struct.unpack('>?', c)[0])
