Skip to content

test.test_math.MathTests.testAtan2 failure on OpenIndiana/Solaris #138573

Description

@mtelka

I do see the following failure with Python-3.14.0rc2 on OpenIndiana. This is a regression from Python-3.13.7.

======================================================================
ERROR: testAtan2 (test.test_math.MathTests.testAtan2)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/data/builds/ul-workspace/components/python/python-314/Python-3.14.0rc2/Lib/test/test_math.py", line 339, in testAtan2
    self.ftest('atan2(0., -0.)', math.atan2(0., -0.), math.pi)
                                 ~~~~~~~~~~^^^^^^^^^
ValueError: math domain error

----------------------------------------------------------------------

Linked PRs

Activity

  1. StanFromIreland commented on Sep 6, 2025

    @StanFromIreland
    Member

    Also occurs on our Solaris buildbot.

    I actually talked about this with @kulikjak, and this is an issue on their side. So there isn't anything for us to do.

  2. changed the title [-]`test.test_math.MathTests.testAtan2` failure on OpenIndiana[/-] [+]`test.test_math.MathTests.testAtan2` failure on OpenIndiana/Solaris[/+] on Sep 6, 2025
  3. terryjreedy commented on Sep 6, 2025

    @terryjreedy
    Member

    Does that mean we should close this?

  4. skirpichev commented on Sep 6, 2025

    @skirpichev
    Member

    math.atan2 is essentially a thin wrapper over libm's atan2:

    cpython/Modules/mathmodule.c

    Lines 1100 to 1103 in 8554c09

    FUNC2(atan2, atan2,
    "atan2($module, y, x, /)\n--\n\n"
    "Return the arc tangent (measured in radians) of y/x.\n\n"
    "Unlike atan(y/x), the signs of both x and y are considered.")

    cpython/Modules/mathmodule.c

    Lines 1014 to 1047 in 8554c09

    static PyObject *
    math_2(PyObject *const *args, Py_ssize_t nargs,
    double (*func) (double, double), const char *funcname)
    {
    double x, y, r;
    if (!_PyArg_CheckPositional(funcname, nargs, 2, 2))
    return NULL;
    x = PyFloat_AsDouble(args[0]);
    if (x == -1.0 && PyErr_Occurred()) {
    return NULL;
    }
    y = PyFloat_AsDouble(args[1]);
    if (y == -1.0 && PyErr_Occurred()) {
    return NULL;
    }
    errno = 0;
    r = (*func)(x, y);
    if (isnan(r)) {
    if (!isnan(x) && !isnan(y))
    errno = EDOM;
    else
    errno = 0;
    }
    else if (isinf(r)) {
    if (isfinite(x) && isfinite(y))
    errno = ERANGE;
    else
    errno = 0;
    }
    if (errno && is_error(r, 1))
    return NULL;
    else
    return PyFloat_FromDouble(r);
    }

    I don't think something was changed here since v3.13 other than using libm's isinf/isnan macro directly.

    It looks like in the given case platform's atan2 returns a nan. @mtelka, could you verify this?

    Correct answer is pi, see https://en.cppreference.com/w/c/numeric/math/atan2.html (Assuming IEEE 754-compatible behavior.) @mtelka, did you test on same version of the OS? This looks as a regression for me, but not in the CPython.

    Edit: I assume, that we won't add a workaround for unsupported broken platform. Or?

  5. added
    pendingThe issue will be closed if no feedback is provided
    on Sep 6, 2025
  6. StanFromIreland commented on Sep 6, 2025

    @StanFromIreland
    Member

    math.atan2 is essentially a thin wrapper over libm's atan2:

    Yes, as I said, this is an issue in their library, which they hope to fix soon.

  7. skirpichev commented on Sep 6, 2025

    @skirpichev
    Member

    Ok, let's close. I don't think workaround is needed.

  8. removed
    pendingThe issue will be closed if no feedback is provided
    on Sep 6, 2025
  9. mtelka commented on Sep 6, 2025

    @mtelka
    ContributorAuthor

    I tested this simple C:

    #include <math.h>
    #include <stdio.h>
    
    int main(void)
    {
            printf("%f\n", atan2(0., -0.));
            return 0;
    }
    

    and here is the result:

    $ gcc -Wall -o test test.c 
    $ ./test 
    3.141593
    $
    

    How can I prove the issue is with the platform?

  10. 32 remaining items

  11. added a commit that references this issue on Mar 25, 2026
  12. skirpichev commented on Mar 25, 2026

    @skirpichev
    Member
  13. removed their assignment
    on Mar 25, 2026
  14. vstinner commented on Mar 25, 2026

    @vstinner
    Member

    (I found mentions of this behavior on our bug tracker from 1988)

    Wow, this is an old bug! 😄

    For completeness, here is list of failed tests on OpenIndiana with Python 3.13.7:

    6 tests failed:
    test.test_asyncio.test_ssl test_cext test_cppext test_embed
    test_shutil test_socket

    I'm interested by test_cext and test_cppext failures, but also by test_embed failure. Would you mind to open an issue for test_cext+test_cppext and another one for test_embed?

  15. added a commit that references this issue on Mar 25, 2026
  16. added a commit that references this issue on Mar 25, 2026
  17. vstinner commented on Mar 25, 2026

    @vstinner
    Member

    The two failing tests are now skipped on Solaris: 8e1469c. The change will be backported to 3.14 once the CI pass on the PR.

    Thanks for your bug report @mtelka.

  18. vstinner commented on Mar 25, 2026

    @vstinner
    Member

    Okay, it looks like the issue is really with the platform, so I reported the bug at https://www.illumos.org/issues/17602.

    Oh, this issue has been fixed by the change illumos/illumos-gate@2eba8eb in the meanwhile, nice!

    We do have only one libm implementation, so yes.

    What is lib_version != libm_ieee test in the implementation? It's possible to select a "lib_version" to get different behaviors?

  19. added a commit that references this issue on Mar 26, 2026
  20. mtelka commented on Mar 26, 2026

    @mtelka
    ContributorAuthor

    We do have only one libm implementation, so yes.

    What is lib_version != libm_ieee test in the implementation? It's possible to select a "lib_version" to get different behaviors?

    I do not think so. However, there was a discussion about this line during the code review. You can find it here: https://code.illumos.org/c/illumos-gate/+/4476

  21. mtelka commented on Mar 26, 2026

    @mtelka
    ContributorAuthor

    I'm interested by test_cext and test_cppext failures, but also by test_embed failure. Would you mind to open an issue for test_cext+test_cppext and another one for test_embed?

    These tests pass with Python 3.14.3.

  22. kulikjak commented on Mar 31, 2026

    @kulikjak
    Contributor

    Thank you for the merge. We still didn't fix (or change) the atan2 behavior, so the skip at least helps us.

  23. added a commit that references this issue on Apr 16, 2026
  24. added a commit that references this issue on Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-unsupportedextension-modulesC modules in the Modules dirtestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions