diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-09-10 13:55:07 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-09-10 13:55:07 (GMT) |
commit | c60542b12bdf11487b959bbb304f4ea194be6a19 (patch) | |
tree | 8348fc4667e247b4f382dfc263dcb9b8f559c1f0 /Lib/test/test_time.py | |
parent | ff0ed3e71cb828103cf21442231686f1b348479b (diff) | |
download | cpython-c60542b12bdf11487b959bbb304f4ea194be6a19.zip cpython-c60542b12bdf11487b959bbb304f4ea194be6a19.tar.gz cpython-c60542b12bdf11487b959bbb304f4ea194be6a19.tar.bz2 |
pytime: add _PyTime_check_mul_overflow() macro to avoid undefined behaviour
Overflow test in test_FromSecondsObject() fails on FreeBSD 10.0 buildbot which
uses clang. clang implements more aggressive optimization which gives
different result than GCC on undefined behaviours.
Check if a multiplication will overflow, instead of checking if a
multiplicatin had overflowed, to avoid undefined behaviour.
Add also debug information if the test on overflow fails.
Diffstat (limited to 'Lib/test/test_time.py')
-rw-r--r-- | Lib/test/test_time.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 30b01d5..f883c45 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -781,7 +781,8 @@ class CPyTimeTestCase: overflow_values = convert_values(ns_timestamps) for time_rnd, _ in ROUNDING_MODES : for value in overflow_values: - with self.assertRaises(OverflowError): + debug_info = {'value': value, 'rounding': time_rnd} + with self.assertRaises(OverflowError, msg=debug_info): pytime_converter(value, time_rnd) def check_int_rounding(self, pytime_converter, expected_func, |