Bug description:
math.tanpi is singular at every odd half-integer, and m_tanpi in Modules/mathmodule.c has an explicit branch for that case, but nothing exercises it. None of the 279 tanpi rows in Lib/test/mathdata/math_testcases.txt has a half-integer argument, and Lib/test/test_math.py never names tanpi.
Adding a row for it does not work as written, because the flag that describes this case makes test_mtestfile fail:
$ echo 'tanpi20004 tanpi 0.5 -> inf divide-by-zero' >> Lib/test/mathdata/math_testcases.txt
$ ./python -m test test_math -m test_mtestfile
...
AssertionError: Failures in test_mtestfile:
tanpi20004: tanpi[0.5]: expected 'ValueError', got 'OverflowError' (not equal)
...
Result: FAILURE
The header of math_testcases.txt defines divide-by-zero as "raised when a finite input gives a mathematically infinite result", which is what happens at the pole, and test_mtestfile maps that flag to ValueError, while math.tanpi(0.5) raises OverflowError. The other flag, overflow, passes, but the same header defines it as "raised when a finite input gives a finite result that is too large to fit in the usual range of an IEEE 754 double", so the row would record something the file says is false.
Doc/library/math.rst does not mention the poles either.
Expected: math.tanpi at an odd half-integer is covered by a test, with a flag that matches the file's own definitions.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug description:
math.tanpiis singular at every odd half-integer, andm_tanpiinModules/mathmodule.chas an explicit branch for that case, but nothing exercises it. None of the 279tanpirows inLib/test/mathdata/math_testcases.txthas a half-integer argument, andLib/test/test_math.pynever namestanpi.Adding a row for it does not work as written, because the flag that describes this case makes
test_mtestfilefail:The header of
math_testcases.txtdefinesdivide-by-zeroas "raised when a finite input gives a mathematically infinite result", which is what happens at the pole, andtest_mtestfilemaps that flag toValueError, whilemath.tanpi(0.5)raisesOverflowError. The other flag,overflow, passes, but the same header defines it as "raised when a finite input gives a finite result that is too large to fit in the usual range of an IEEE 754 double", so the row would record something the file says is false.Doc/library/math.rstdoes not mention the poles either.Expected:
math.tanpiat an odd half-integer is covered by a test, with a flag that matches the file's own definitions.CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs