Skip to content

Commit be0ed87

Browse files
committed
Expand comments to explain why we ignore errno
1 parent 288fb8b commit be0ed87

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎Modules/cmathmodule.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,8 +1004,10 @@ cmath_phase_impl(PyObject *module, Py_complex z)
10041004
{
10051005
double phi;
10061006

1007-
phi = atan2(z.imag, z.real); /* should not cause any exception */
1008-
/* gh-153144: Ignore atan2() errno on purpose. */
1007+
phi = atan2(z.imag, z.real);
1008+
/* gh-153144: Ignore atan2() errno on purpose since it can optionally be
1009+
* EDOM, which we should ignore, or ERANGE if phi underflows,
1010+
* which is silent on Python. Overflow is not possible. */
10091011
return PyFloat_FromDouble(phi);
10101012
}
10111013

‎Modules/mathmodule.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,11 +1149,14 @@ FUNC1(atan, atan, 0,
11491149
"atan($module, x, /)\n--\n\n"
11501150
"Return the arc tangent (measured in radians) of x.\n\n"
11511151
"The result is between -pi/2 and pi/2.")
1152-
FUNC2NE(atan2, atan2, // gh-153144: Ignore atan2() errno on purpose.
1152+
/* gh-153144: Ignore atan2 and atan2pi errno on purpose since it can optionally
1153+
* be EDOM, which we should ignore, or ERANGE on underflow, which is
1154+
* silent on Python. Overflow is not possible. */
1155+
FUNC2NE(atan2, atan2,
11531156
"atan2($module, y, x, /)\n--\n\n"
11541157
"Return the arc tangent (measured in radians) of y/x.\n\n"
11551158
"Unlike atan(y/x), the signs of both x and y are considered.")
1156-
FUNC2NE(atan2pi, m_atan2pi, // gh-153144: Ignore atan2pi() errno on purpose.
1159+
FUNC2NE(atan2pi, m_atan2pi,
11571160
"atan2pi($module, y, x, /)\n--\n\n"
11581161
"Return the arc tangent (measured in half-turns) of y/x.\n\n"
11591162
"Unlike atanpi(y/x), the signs of both x and y are considered.")

0 commit comments

Comments
 (0)