Make floating-point exception error messages slightly more verbose: in

particular, the error message now allows one to distinguish between a
ValueError arising from a singularity (e.g. log(0.)), which would
usually produce +-infinity in non-stop mode, and a ValueError resulting
from an invalid input (e.g. sqrt(-1.)), which would normally produce a
NaN in non-stop mode.
This commit is contained in:
Mark Dickinson 2008-04-30 23:30:57 +00:00
parent 3cbf15f07a
commit a0de26c342
3 changed files with 24 additions and 21 deletions

View file

@ -741,9 +741,9 @@ class MathTests(unittest.TestCase):
func = getattr(math, fn)
try:
result = func(ar)
except ValueError:
message = ("Unexpected ValueError in " +
"test %s:%s(%r)\n" % (id, fn, ar))
except ValueError as exc:
message = (("Unexpected ValueError: %s\n " +
"in test %s:%s(%r)\n") % (exc.args[0], id, fn, ar))
self.fail(message)
self.ftest("%s:%s(%r)" % (id, fn, ar), result, er)