Test_math failing on OpenBSD 7.5 runing on amd64

Here is the detailed test output:

LD_LIBRARY_PATH=/home/adming/Python-3.13.0b1 ./python -m test.test_math
ERROR: test_fma_overflow (__main__.FMATests.test_fma_overflow)
Traceback (most recent call last):
  File "/home/adming/Python-3.13.0b1/Lib/test/test_math.py", line 2773, in test_fma_overflow
    self.assertEqual(math.fma(a, b, -c),
OverflowError: overflow in fma

Ran 85 tests in 87.649s

FAILED (errors=1)

Could you please open an issue report for this on GitHub?

The test in question is trying a case at the very edge of raising a legitimate overflow error. But your platform C’s fma() function is apparently returning an infinity when it should be returning a finite number.

If that’s the case, Python can’t fix it (it would instead be a bug in your platform’s C implementation). Best we could do is disable this test on your platform.

So when you open the issue report, please tell as much as you know about which C compiler was used to compile Python, and with which options…

Or, if you don’t open an issue report, the matter will be probably be lost forever :wink:.


Given Tim’s suggestion you could write the same fma test as a C program and compare OpenBSD against one of the linux distros.
If you find the same error then report to the OpenBSD project.

1 Like

In the meanwhile, if you write a PR to skip the test on OpenBSD, I can review it. I already skipped some FMA tests on FreeBSD and WASI platforms.

    # gh-73468: On some platforms, libc fma() doesn't implement IEE 754-2008
    # properly: it doesn't use the right sign when the result is zero.
        sys.platform.startswith(("freebsd", "wasi"))
        or (sys.platform == "android" and platform.machine() == "x86_64"),
        f"this platform doesn't implement IEE 754-2008 properly")
    def test_fma_zero_result(self):

There was also other issue with inprecise math on OpenBSD: math.tan has poor accuracy near pi/2 on OpenBSD and NetBSD · Issue #75811 · python/cpython · GitHub. I hope this was fixed in the later versions.