[New-bugs-announce] [issue1879] sqrt(-1) doesn't raise ValueError on OS X
Mark Dickinson
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
>>> sqrt(-1)
nan
>>> log(-1)
nan
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
files: sqrt_minus_one.patch
keywords: patch
messages: 61373
nosy: marketdickinson
priority: normal
severity: normal
status: open
title: sqrt(-1) doesn't raise ValueError on OS X
type: behavior
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>
<http://bugs.python.org/issue1879>
__________________________________
More information about the New-bugs-announce
mailing list