gh-157859: Fix cmath.atanh() returning inf at ±1 ± sqrt(DBL_MIN)*1j - #157860
Open
greg-const wants to merge 1 commit into
Open
greg-const wants to merge 1 commit into
greg-const wants to merge 1 commit into
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
greg-const
force-pushed
the
fix-cmath-atanh-boundary
branch
from
September 20, 2026 12:53
e18c47a to
eb544f9
Compare
skirpichev
reviewed
Sep 20, 2026
…)*1j cmath_atanh_impl() selects its near-pole formula with `ay < CM_SQRT_DBL_MIN`. At equality the general formula computes 4/(0 + ay*ay) = 4/DBL_MIN, which overflows, so the finite input 1 + 2**-511j (and its three sign/conjugate mirrors, and the corresponding cmath.atan() inputs) returned inf. Use `<=` so the boundary word takes the near-pole formula, which is accurate there.
greg-const
force-pushed
the
fix-cmath-atanh-boundary
branch
from
September 20, 2026 13:20
eb544f9 to
e385873
Compare
skirpichev
self-requested a review
September 20, 2026 14:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #157859.
Use the near-pole formula in
cmath_atanh_impl()whenay == CM_SQRT_DBL_MIN, as well as when it is smaller.At the boundary, the general formula forms
4.0 / DBL_MIN, whichoverflows even though the result is finite. Changing
<to<=avoidsthat intermediate overflow. This also fixes the corresponding
cmath.atan()inputs, sincecmath.atan()uses the same implementation.Add a regression test for both functions, covering all four sign
combinations and the immediately adjacent floating-point inputs. The test
fails without the C change and passes with it.
Testing
The full test run reported failures in
test_socket(
testInterruptedTimeout) andtest.test_asyncio.test_ssl. Both passedwhen rerun.
testInterruptedTimeoutalso fails on an unpatched build inthe same environment, so these failures appear unrelated to this change.
patchcheckpasses apart from the expected NEWS entry added withblurb.