diff options
author | Meador Inge <meadori@gmail.com> | 2012-05-28 18:52:59 (GMT) |
---|---|---|
committer | Meador Inge <meadori@gmail.com> | 2012-05-28 18:52:59 (GMT) |
commit | fe7aa49f24743f834bcf123fcd9ea5cc7a123209 (patch) | |
tree | dc71e0f747867b88e6207536c638578ccdf7222a /Lib/ctypes | |
parent | d9d276b0dcd5b8108d5b906f83e53b95a7ac686d (diff) | |
download | cpython-fe7aa49f24743f834bcf123fcd9ea5cc7a123209.zip cpython-fe7aa49f24743f834bcf123fcd9ea5cc7a123209.tar.gz cpython-fe7aa49f24743f834bcf123fcd9ea5cc7a123209.tar.bz2 |
Issue #9041: raised exception is misleading
An issue in ctypes.c_longdouble, ctypes.c_double, and ctypes.c_float that
caused an incorrect exception to be returned in the case of overflow has been
fixed.
Diffstat (limited to 'Lib/ctypes')
-rw-r--r-- | Lib/ctypes/test/test_numbers.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/ctypes/test/test_numbers.py b/Lib/ctypes/test/test_numbers.py index 2267693..7923906 100644 --- a/Lib/ctypes/test/test_numbers.py +++ b/Lib/ctypes/test/test_numbers.py @@ -216,6 +216,16 @@ class NumberTestCase(unittest.TestCase): # probably be changed: self.assertRaises(TypeError, c_int, c_long(42)) + def test_float_overflow(self): + import sys + big_int = int(sys.float_info.max) * 2 + for t in float_types + [c_longdouble]: + self.assertRaises(OverflowError, t, big_int) + if (hasattr(t, "__ctype_be__")): + self.assertRaises(OverflowError, t.__ctype_be__, big_int) + if (hasattr(t, "__ctype_le__")): + self.assertRaises(OverflowError, t.__ctype_le__, big_int) + ## def test_perf(self): ## check_perf() |