You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test.test_math.MathTests.testAtan2 failure on OpenIndiana/Solaris #138573
I assume in both cases same libm is used (I don't know how you build Python).
Well, as you can see from linked above math_2() code, "math domain error" can arise only in if(isnan(r)) branch on L1031. Is isnan() macro working as expected on your system?
I assume in both cases same libm is used (I don't know how you build Python).
We do have only one libm implementation, so yes.
Well, as you can see from linked above math_2() code, "math domain error" can arise only in if(isnan(r)) branch on L1031. Is isnan() macro working as expected on your system?
I'm not sure if the following serves as a proof the isnan() works, but I'm not aware about any issue there.
Hi, from my investigation, the problem is that atan2 on Solaris sets errno when both arguments are +-0 (the result is correct, though). This was the case for many many years (I found mentions of this behavior on our bug tracker from 1988), so it likely affects all Solaris forks as well. Python 3.14 likely just added a new test that uncovered this.
I personally think this should not be the case and reported this internally, but I don't know when or whether it will get fixed considering how long this has been the case.
if implementation conforms to Annex F. Then __STDC_IEC_559__ should be defined. Can you confirm it's not defined?
If not, standard says: "A domain error may occur if both arguments are zero."
Comment from mathmodule.c says:
In general, on an IEEE-754 platform the aim is to follow the C99 standard, including Annex 'F', whenever possible.
So, I don't think we should either add a workaround or fix the test. Though, maybe we can filter it out for implementations, that don't conform to Annex F.
I think macro __STDC_IEC_559__ - should be exposed somewhere, maybe in sys.float_info? Or in the math module itself.
Python 3.14 likely just added a new test that uncovered this.
Git blame thinks this come from old commit (e57950f).
Since both Solaris and illumos does not define __STDC_IEC_559__ then it should be okay for them to return EDOM for the atan2(0.0, 0.0) case (as already mentioned above by @skirpichev). Isn't the bug really at the Python side then where Python silently expects that all implementations are IEC 60559 conformant even in a case they do not claim so?
In pr #138812 this test restricted to the IEC 60559-compatible platforms.
I'm not sure that it's The Right Way. Perhaps, we can factor out only tests where F.10.1.4 and 7.12.4.4 of the C standard (e.g. C17) differ (i.e. both arguments are zeros). But I suspect other non-IEEE platforms have more quirks when arguments and/or result are zero.
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?
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?
Activity
skirpichev commentedon Sep 6, 2025
I assume in both cases same libm is used (I don't know how you build Python).
Well, as you can see from linked above math_2() code, "math domain error" can arise only in
if(isnan(r))branch on L1031. Is isnan() macro working as expected on your system?mtelka commentedon Sep 6, 2025
We do have only one libm implementation, so yes.
I'm not sure if the following serves as a proof the
isnan()works, but I'm not aware about any issue there.For completeness, here is list of failed tests on OpenIndiana with Python 3.13.7:
And yes, I do build both 3.13.7 and 3.14.0rc0 on the same machine using same steps (or as close as possible).
mtelka commentedon Sep 6, 2025
This is another related failure I do see with 3.14.0rc2:
skirpichev commentedon Sep 6, 2025
Then probably libm's atan2 just set errno to EDOM if both arguments are zero. This happens for non IEEE-compliant systems.
kulikjak commentedon Sep 6, 2025
Hi, from my investigation, the problem is that
atan2on Solaris sets errno when both arguments are +-0 (the result is correct, though). This was the case for many many years (I found mentions of this behavior on our bug tracker from 1988), so it likely affects all Solaris forks as well. Python 3.14 likely just added a new test that uncovered this.I personally think this should not be the case and reported this internally, but I don't know when or whether it will get fixed considering how long this has been the case.
skirpichev commentedon Sep 6, 2025
@kulikjak, thanks. That confirms my guess above, sorry it wasn't first.
C17 says for atan2:
if implementation conforms to Annex F. Then
__STDC_IEC_559__should be defined. Can you confirm it's not defined?If not, standard says: "A domain error may occur if both arguments are zero."
Comment from mathmodule.c says:
So, I don't think we should either add a workaround or fix the test. Though, maybe we can filter it out for implementations, that don't conform to Annex F.
I think macro
__STDC_IEC_559__- should be exposed somewhere, maybe in sys.float_info? Or in the math module itself.Git blame thinks this come from old commit (e57950f).
mtelka commentedon Sep 6, 2025
What about this?
@kulikjak does the above print non-zero on 2nd line on Solaris?
mtelka commentedon Sep 6, 2025
For reference, here is the illumos man page: https://illumos.org/man/3M/atan2
mtelka commentedon Sep 6, 2025
I do not see it defined on illumos.
skirpichev commentedon Sep 6, 2025
Then I suggest you to run math.atan2(0., -0.) under debugger.
I see no other options where EDOM might be set: either isnan(r) test or the libm's atan2 itself.
Yes, it looks to be compatible with Annex F.
So, it doesn't claims to be IEEE-compliant. We should just filter out this test. But I'm curious why it doesn't work and appreciate debugging.
kulikjak commentedon Sep 6, 2025
This also prints zero on Solaris, but if you pass in doubles from variables, it no longer does so - interesting...
Same here.
mtelka commentedon Sep 6, 2025
The difference is that
atan2(0., -0.)is evaluated during the compile, whileatan2(x, y)is not.mtelka commentedon Sep 6, 2025
Okay, it looks like the issue is really with the platform, so I reported the bug at https://www.illumos.org/issues/17602.
mtelka commentedon Sep 6, 2025
While thinking more about this...
Since both Solaris and illumos does not define
__STDC_IEC_559__then it should be okay for them to returnEDOMfor theatan2(0.0, 0.0)case (as already mentioned above by @skirpichev). Isn't the bug really at the Python side then where Python silently expects that all implementations are IEC 60559 conformant even in a case they do not claim so?skirpichev commentedon Sep 6, 2025
Yes, I think we should filter out test (or rather part of it). I'm working on it, see created issue above.
kulikjak commentedon Sep 8, 2025
Makes sense, and it's one more reason it should be fixed on our side.
But I agree that Python probably shouldn't expect that the implementation is IEEE-compliant.
pythongh-138573: restrict testAtan2() the IEC 60559-compatible platforms
skirpichev commentedon Sep 12, 2025
In pr #138812 this test restricted to the IEC 60559-compatible platforms.
I'm not sure that it's The Right Way. Perhaps, we can factor out only tests where F.10.1.4 and 7.12.4.4 of the C standard (e.g. C17) differ (i.e. both arguments are zeros). But I suspect other non-IEEE platforms have more quirks when arguments and/or result are zero.
mtelka commentedon Sep 12, 2025
FYI, here is the full list of related tests I had to remove to see both
test_mathandtest_cmathpassing:skirpichev commentedon Sep 13, 2025
All related to atan2(), when both arguments are zeros. (cmath.phase() is just atan2 wrapper.)
pythongh-138573: filter out failing math tests on Solaris
skirpichev commentedon Mar 25, 2026
@mtelka, see #146402.
vstinner commentedon Mar 25, 2026
Wow, this is an old bug! 😄
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?
gh-138573: Filter out failing math tests on Solaris (#146402)
pythongh-138573: Filter out failing math tests on Solaris (pythonGH-1…
vstinner commentedon Mar 25, 2026
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.
vstinner commentedon Mar 25, 2026
Oh, this issue has been fixed by the change illumos/illumos-gate@2eba8eb in the meanwhile, nice!
What is
lib_version != libm_ieeetest in the implementation? It's possible to select a "lib_version" to get different behaviors?[3.14] gh-138573: Filter out failing math tests on Solaris (GH-146402) (
mtelka commentedon Mar 26, 2026
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
mtelka commentedon Mar 26, 2026
These tests pass with Python 3.14.3.
kulikjak commentedon Mar 31, 2026
Thank you for the merge. We still didn't fix (or change) the
atan2behavior, so the skip at least helps us.pythongh-138573: Filter out failing math tests on Solaris (python#146402
pythongh-138573: Filter out failing math tests on Solaris (python#146402