[issue1879] sqrt(-1) doesn't raise ValueError on OS X
report at bugs.python.org
Mon Jan 21 03:51:29 CET 2008
New submission from Mark Dickinson:
On OS X 10.4, and probably other versions of OS X too, calls to math.log and math.sqrt that
should raise ValueError instead return a NaN:
Python 2.6a0 (trunk:60144, Jan 20 2008, 21:43:56)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from math import sqrt, log
The problem is that OS X doesn't set errno in these cases. Attached is a quick fix for this.
Note that there's already a test for this (test_exceptions in test_math.py), but this test is
only run in verbose mode.
See also issue #871657.
components: Extension Modules
title: sqrt(-1) doesn't raise ValueError on OS X
versions: Python 2.5, Python 2.6, Python 3.0
Added file: http://bugs.python.org/file9247/sqrt_minus_one.patch
Tracker <report at bugs.python.org>
More information about the Python-bugs-list