[New-bugs-announce] [issue37474] Should Py_Initialize() control the floating point mode?

STINNER Victor report at bugs.python.org
Mon Jul 1 13:39:03 EDT 2019


New submission from STINNER Victor <vstinner at redhat.com>:

Just after calling _PyRuntime_Initialize(), Py_Main() calls:

    /* 754 requires that FP exceptions run in "no stop" mode by default,
     * and until C vendors implement C99's ways to control FP exceptions,
     * Python requires non-stop mode.  Alas, some platforms enable FP
     * exceptions by default.  Here we disable them.
     */
#ifdef __FreeBSD__
    fedisableexcept(FE_OVERFLOW);
#endif

It's done before calling Py_Initialize(). So applications embedding Python don't call it. But "customized Python" which call the new Py_RunMain() with Py_InititializeFromConfig() will not call it neither.

I would like to know if this setup code should be moved into Py_Initialize()? Especially into the new PyConfig API:
https://docs.python.org/dev/c-api/init_config.html

PyConfig got 2 flags to control parameters which affect the whole process:

* configure_c_stdio
* configure_locale

What is the behavior on FreeBSD when fedisableexcept(FE_OVERFLOW) is not called?

Note: I'm not sure why this call is only needed on FreeBSD, but not on macOS, OpenBSD or NetBSD (operating systems close to FreeBSD).

----------
components: Interpreter Core
messages: 347048
nosy: lemburg, mark.dickinson, stutzbach, vstinner
priority: normal
severity: normal
status: open
title: Should Py_Initialize() control the floating point mode?
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37474>
_______________________________________


More information about the New-bugs-announce mailing list