mirror of
https://github.com/python/cpython.git
synced 2025-11-26 21:33:10 +00:00
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.
This commit is contained in:
parent
d9d276b0dc
commit
fe7aa49f24
3 changed files with 19 additions and 25 deletions
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue