summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_struct.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-07-07 18:54:59 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-07-07 18:54:59 (GMT)
commitde73c4587f665bdbf748715461691e9584f30c0f (patch)
treeb60e603250af75b81fc6c6b2b2c79701248ae947 /Lib/test/test_struct.py
parente789016a70c161829627bf7497238f2d52b4b004 (diff)
downloadcpython-de73c4587f665bdbf748715461691e9584f30c0f.zip
cpython-de73c4587f665bdbf748715461691e9584f30c0f.tar.gz
cpython-de73c4587f665bdbf748715461691e9584f30c0f.tar.bz2
don't ignore exceptions from PyObject_IsTrue
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r--Lib/test/test_struct.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 8448286..3168a7b 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -475,6 +475,9 @@ class StructTest(unittest.TestCase):
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 @@ class StructTest(unittest.TestCase):
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])