summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-07-07 22:46:00 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-07-07 22:46:00 (GMT)
commitf092c7c1d7bfcd07dfe621b0b21ab4ece2434c57 (patch)
treeb1cfb4e3de9ce76738cc465af0cf83978d4f9908 /Lib/test
parentddd46ceeb0b37cd639fa45cfe847fce668806d7a (diff)
downloadcpython-f092c7c1d7bfcd07dfe621b0b21ab4ece2434c57.zip
cpython-f092c7c1d7bfcd07dfe621b0b21ab4ece2434c57.tar.gz
cpython-f092c7c1d7bfcd07dfe621b0b21ab4ece2434c57.tar.bz2
Merged revisions 82628,82630 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r82628 | benjamin.peterson | 2010-07-07 13:44:05 -0500 (Wed, 07 Jul 2010) | 1 line this needn't be in the loop ........ r82630 | benjamin.peterson | 2010-07-07 13:54:59 -0500 (Wed, 07 Jul 2010) | 1 line don't ignore exceptions from PyObject_IsTrue ........
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_struct.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 6032895..8840462 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -480,6 +480,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
@@ -508,8 +511,11 @@ class StructTest(unittest.TestCase):
self.assertFalse(prefix, msg='encoded bool is not one byte: %r'
%packed)
- for c in [b'\x01', b'\x7f', b'\xff', b'\x0f', b'\xf0']:
- self.assertTrue(struct.unpack('>?', c)[0])
+ 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])
def test_count_overflow(self):
hugecount = '{}b'.format(sys.maxsize+1)