[Python-bugs-list] [ python-Bugs-614060 ] fpectl module broken on Linux
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 24 Sep 2002 14:46:25 -0700
Bugs item #614060, was opened at 2002-09-24 15:46
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=614060&group_id=5470
Category: Extension Modules
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Mats Wichmann (mwichmann)
Assigned to: Nobody/Anonymous (nobody)
Summary: fpectl module broken on Linux
Initial Comment:
Initial (minor) issue was that fpectl.c issues an unused
variable warning compiling on Linux Itanium (ia64). On
Itanium the _FPU_SETCW(cw) macro is a stub which
does not reference cw. Turns out fpectl.c issues an
explicit write of 0x1372 to the fpu control register via this
macro, if found in the headers. With some further
digging, here's the story as it seems on Linux:
(1) fpectl.tex is out of date with respect to current
behavior. Here's an excerpt (markup removed):
+++++++
some floating point operations produce results that
cannot be expressed as a normal floating point value.
For example, try
>>> import math
>>> math.exp(1000)
inf
>>> math.exp(1000) / math.exp(1000)
nan
+++++++
However, current Python behaves like this:
>>> math.exp(1000)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OverflowError: math range error
(2) the fpectl module has no effect on ia64, where it's
simply a stub. Behavior on other platforms such as
Sparc, powerpc, etc might be unpredictable.
(3) on i386, use of fpectl will cause Python to crash:
Python 2.2.1 (#1, Jul 29 2002, 15:14:33)
[GCC 3.2 (Mandrake Linux 9.0 3.2-0.1mdk)] on linux-i386
Type "help", "copyright", "credits" or "license" for more
information.
>>> import fpectl
>>> import math
>>> fpectl.turnon_sigfpe()
>>> math.exp(1000)
Fatal Python error: Unprotected floating point exception
Aborted
$
(4) Linux/glibc documentation suggests that the
preferred interface for manipulating IEEE floating point
exception and rouding behavior is with C99 standard
routines fesetround() and fesetenv().
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=614060&group_id=5470