Four statements added with the half-turn functions in GH-150555 describe a different function than the one they document.
$ ./python -c 'import math; print(math.atanpi.__doc__); print(math.atanpi(-1), math.atan2pi(-1, -1), math.atanpi(-1 / -1))'
Return the arc tangent (measured in half-turns) of x.
The result is between 0 and 1.
-0.25 -0.75 0.25
atanpi's docstring in Modules/mathmodule.c says "The result is between 0 and 1". The range is -1/2 to 1/2, as Doc/library/math.rst states.
The trigonometric summary table in Doc/library/math.rst describes atan2pi(y, x) as "atan(y / x), in half-turns". atan returns radians, and the entry for the function itself says atanpi(y / x).
The comment above m_atanpi in Modules/mathmodule.c reads "asin(x)/pi". The function computes atan(x)/pi.
The comment above m_atan2pi in Modules/mathmodule.c reads "asin(x)/pi". The function computes atan2(y, x)/pi.
changed the title [-]`math.atanpi` docstring states the wrong result range[/-][+]Documentation errors in the new half-turn `*pi` functions[/+]on Sep 7, 2026
Activity
gh-157135: Fix documentation errors in the `math.atan{2}pi` functions (…
Merge branch 'main' into tachyon-native-callable
pythongh-157135: Fix documentation errors in the `math.atan{2}pi` fun…
pythongh-157135: Fix documentation errors in the `math.atan{2}pi` fun…