This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: fpectl module broken on Linux
Type: Stage:
Components: Extension Modules Versions: Python 2.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, mwichmann
Priority: normal Keywords:

Created on 2002-09-24 21:46 by mwichmann, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (2)
msg12474 - (view) Author: Mats Wichmann (mwichmann) * Date: 2002-09-24 21:46
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)
>>> math.exp(1000) / math.exp(1000)
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 
>>> import fpectl
>>> import math
>>> fpectl.turnon_sigfpe()
>>> math.exp(1000)
Fatal Python error: Unprotected floating point exception

(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().
msg12475 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2002-11-08 13:10
Logged In: YES 

The fpectl module has been removed from the in CVS and in Python 2.2.2, so it will no longer be compiled automatically. Thanks for pointing this out.

Marking this bug as closed; figuring out a new interface for FPE control will probably need a PEP.
Date User Action Args
2022-04-10 16:05:42adminsetgithub: 37215
2002-09-24 21:46:25mwichmanncreate