Skip to content
Open
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
The copysign function does not need to check errno.
  • Loading branch information
hpkfft committed Aug 30, 2026
commit d546e8120b94782e22dbf604841c5e584c46a85e
4 changes: 2 additions & 2 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ math_1a(PyObject *arg, double (*func) (double), const char *err_msg)
The last rule is used to catch overflow on platforms which follow
C89 but for which HUGE_VAL is not an infinity.

For most two-argument functions (copysign, fmod, hypot)
For most two-argument functions (fmod, hypot)

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.

Actually, the only remaining math_2()-type function is remainder()...

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.

I think (fmod, hypot) in the comment above refers to the C math library functions.
Unless I've missed it, Python does not use the C math library function double remainder(double, double), so I don't think we should add it to this comment.

@skirpichev skirpichev Oct 5, 2026 •

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.

I think (fmod, hypot) in the comment above refers to the C math library functions.

I don't think so. Before 53876d9, both fmod and hypot were using FUNC2 macro.

Python does not use the C math library function double remainder(double, double)

Yes, but m_remainder (name in style m_log and co, suggesting a workarounded libm's function) is just an implementation of Annex F remainder.

Perhaps, nowadays we could replace this function by standard library call: at least this works well for me locally. See previous attempt of removing legacy stuff: #101679

Edit: FYI, #158826.

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.

Interesting. But it seems sufficiently unrelated as to allow this PR to be merged without further tweaks to the comments.

these rules are enough to ensure that Python's functions behave as
specified in 'Annex F' of the C99 standard, with the 'invalid' and
'divide-by-zero' floating-point exceptions mapping to Python's
Expand Down Expand Up @@ -1206,7 +1206,7 @@ math_ceil(PyObject *module, PyObject *number)
return PyLong_FromDouble(ceil(x));
}

FUNC2(copysign, copysign,
FUNC2NE(copysign, copysign,
Comment thread
picnixz marked this conversation as resolved.
"copysign($module, x, y, /)\n--\n\n"
"Return a float with the magnitude (absolute value) of x but the sign of y.\n\n"
"On platforms that support signed zeros, copysign(1.0, -0.0)\n"
Expand Down
Loading