[Python-bugs-list] math.log(0) dumps core (PR#152)

Guido van Rossum guido@CNRI.Reston.VA.US
Tue, 07 Dec 1999 23:13:34 -0500


> Full_Name: Cliff Crawford
> Version: 1.5.2
> OS: FreeBSD 3.3-STABLE
> Submission from: ith1-379.twcny.rr.com (24.24.11.121)
> 
> 
> math.log(0) and math.log(0.0) both cause the interpreter to dump core.
> Sample output:
> 
> bridget:~$ uname -a
> FreeBSD bridget.mindriot.net 3.3-STABLE FreeBSD 3.3-STABLE #19: Fri Oct  8
> 20:01:29 EDT 1999    
> root@tankgrrl.bridget.mindriot.net:/usr/src/sys/compile/CJC26  i386
> bridget:~$ python
> Python 1.5.2 (#25, Jun 21 1999, 18:19:49)  [GCC egcs-2.91.60 19981201
> (egcs-1.1.1  on freebsd3
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import math
> >>> math.log(0)
> Floating point exception (core dumped)

I'm sorry, but this is a bug in the C math library of your platform.
The C function is supposed to return an error which Python translates
into an exception; on correct platforms the following behavior is
observed:

>>> import math
>>> math.log(0)
Traceback (innermost last):
  File "<pyshell#1>", line 1, in ?
    math.log(0)
OverflowError: math range error
>>> math.log(0.0)
Traceback (innermost last):
  File "<pyshell#2>", line 1, in ?
    math.log(0.0)
OverflowError: math range error
>>>

--Guido van Rossum (home page: http://www.python.org/~guido/)