diff --git a/Lib/test/mathdata/math_testcases.txt b/Lib/test/mathdata/math_testcases.txt index 4a38a3666bab20..843766673afef9 100644 --- a/Lib/test/mathdata/math_testcases.txt +++ b/Lib/test/mathdata/math_testcases.txt @@ -1311,9 +1311,9 @@ atan2pi20000 atan2pi inf 0 -> 0.5 atan2pi20001 atan2pi -inf 0 -> -0.5 atan2pi20002 atan2pi nan 0 -> nan -atan2pi20000 atan2pi inf -0 -> 0.5 -atan2pi20001 atan2pi -inf -0 -> -0.5 -atan2pi20002 atan2pi nan -0 -> nan +atan2pi21000 atan2pi inf -0 -> 0.5 +atan2pi21001 atan2pi -inf -0 -> -0.5 +atan2pi21002 atan2pi nan -0 -> nan atan2pi20003 atan2pi inf 1 -> 0.5 atan2pi20004 atan2pi -inf 1 -> -0.5 @@ -1339,9 +1339,9 @@ atan2pi30000 atan2pi 0 inf -> 0.0 atan2pi30001 atan2pi 0 -inf -> 1.0 atan2pi30002 atan2pi 0 nan -> nan -atan2pi30000 atan2pi -0 inf -> -0.0 -atan2pi30001 atan2pi -0 -inf -> -1.0 -atan2pi30002 atan2pi -0 nan -> nan +atan2pi31000 atan2pi -0 inf -> -0.0 +atan2pi31001 atan2pi -0 -inf -> -1.0 +atan2pi31002 atan2pi -0 nan -> nan atan2pi30003 atan2pi 1 inf -> 0.0 atan2pi30004 atan2pi 1 -inf -> 1.0 @@ -2247,3 +2247,8 @@ tanpi10275 tanpi -1.6591963470121216 -> 1.829921944286168 tanpi20001 tanpi inf -> nan invalid tanpi20002 tanpi -inf -> nan invalid tanpi20003 tanpi nan -> nan + +tanpi30001 tanpi 0.5 -> inf invalid +tanpi30002 tanpi -0.5 -> -inf invalid +tanpi30003 tanpi 1.5 -> -inf invalid +tanpi30004 tanpi -1.5 -> inf invalid diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py index a27996dd01c9d1..a1250c668223e7 100644 --- a/Lib/test/test_math.py +++ b/Lib/test/test_math.py @@ -2144,7 +2144,12 @@ def test_mtestfile(self): fail_fmt = "{}: {}{!r}: {}" failures = [] + ids = set() for id, fn, args, expected, flags in parse_mtestfile(math_testcases): + if id in ids: + failures.append(f"Duplicate test id {id}") + ids.add(id) + func = getattr(math, fn) if 'invalid' in flags or 'divide-by-zero' in flags: diff --git a/Misc/NEWS.d/next/Library/2026-08-17-17-39-41.gh-issue-155966.0YOADY.rst b/Misc/NEWS.d/next/Library/2026-08-17-17-39-41.gh-issue-155966.0YOADY.rst new file mode 100644 index 00000000000000..2f556aef54a63a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-08-17-17-39-41.gh-issue-155966.0YOADY.rst @@ -0,0 +1,2 @@ +:func:`math.tanpi` now raises :exc:`ValueError` for half-integer values +(e.g., ``tanpi(1.5)``), as these are poles of the function. diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index eaa1850b8aee1a..8c05c1c0201008 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -1343,10 +1343,10 @@ FUNC1D(tan, tan, 0, FUNC1(tanh, tanh, 0, "tanh($module, x, /)\n--\n\n" "Return the hyperbolic tangent of x.") -FUNC1D(tanpi, m_tanpi, 1, +FUNC1D(tanpi, m_tanpi, 0, "tanpi($module, x, /)\n--\n\n" "Return the tangent of x (measured in half-turns).", - "expected a finite input, got %s") + "expected a finite input not equal to a half-integer, got %s") /* Precision summation function as msum() by Raymond Hettinger in ,