We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 14a5ad1 commit 3e57644Copy full SHA for 3e57644
Modules/cmathmodule.c
@@ -926,10 +926,19 @@ cmath_phase_impl(PyObject *module, Py_complex z)
926
927
errno = 0;
928
phi = atan2(z.imag, z.real); /* should not cause any exception */
929
- if (errno != 0)
+ if (errno != 0) {
930
+#if defined(__sun)
931
+ /* On Solaris, atan2 incorrectly sets errno when both arguments are
932
+ zero. The result is correct though, so we can safely ignore the
933
+ errno and return it. */
934
+ if ((z.imag == 0.0 || z.imag == -0.0) && (z.real == 0.0 || z.real == -0.0)) {
935
+ return PyFloat_FromDouble(phi);
936
+ }
937
+#endif
938
return math_error();
- else
939
+ } else {
940
return PyFloat_FromDouble(phi);
941
942
}
943
944
/*[clinic input]
0 commit comments