Visitar URL original
gh-153144: Avoid checking `errno` for `atan2` by hpkfft · Pull Request #153148 · python/cpython · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add comments as requested in review
  • Loading branch information
hpkfft committed Aug 14, 2026
commit 25ec8e21831c0c5fa92e48aa1fa1f5edc559d086
1 change: 1 addition & 0 deletions Modules/cmathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ cmath_phase_impl(PyObject *module, Py_complex z)
double phi;

phi = atan2(z.imag, z.real); /* should not cause any exception */
Comment thread
hpkfft marked this conversation as resolved.
Outdated
/* gh-153144: Ignore atan2() errno on purpose. */
Comment thread
hpkfft marked this conversation as resolved.
Outdated
return PyFloat_FromDouble(phi);
}

Expand Down
6 changes: 3 additions & 3 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ math_2ne(PyObject *const *args, Py_ssize_t nargs,
if (y == -1.0 && PyErr_Occurred()) {
return NULL;
}
r = (*func)(x, y);
r = (*func)(x, y); // Ignore errno on purpose.
Comment thread
hpkfft marked this conversation as resolved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
r = (*func)(x, y); // Ignore errno on purpose.
r = (*func)(x, y);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vstinner asked for this comment on August 14: #153148 (comment)

return PyFloat_FromDouble(r);
}

Expand Down Expand Up @@ -1149,11 +1149,11 @@ FUNC1(atan, atan, 0,
"atan($module, x, /)\n--\n\n"
"Return the arc tangent (measured in radians) of x.\n\n"
"The result is between -pi/2 and pi/2.")
FUNC2NE(atan2, atan2,
FUNC2NE(atan2, atan2, // gh-153144: Ignore atan2() errno on purpose.
Comment thread
hpkfft marked this conversation as resolved.
Outdated
"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.")
FUNC2NE(atan2pi, m_atan2pi,
FUNC2NE(atan2pi, m_atan2pi, // gh-153144: Ignore atan2pi() errno on purpose.
Comment thread
hpkfft marked this conversation as resolved.
Outdated
"atan2pi($module, y, x, /)\n--\n\n"
"Return the arc tangent (measured in half-turns) of y/x.\n\n"
"Unlike atanpi(y/x), the signs of both x and y are considered.")
Expand Down