Skip to content

[3.14] gh-153200: Fix math.isqrt() for int subclasses with overridden comparison operators (GH-153203)#153225

Merged
serhiy-storchaka merged 1 commit into
python:3.14from
serhiy-storchaka:backport-3a1b547-3.14
Jul 6, 2026
Merged

[3.14] gh-153200: Fix math.isqrt() for int subclasses with overridden comparison operators (GH-153203)#153225
serhiy-storchaka merged 1 commit into
python:3.14from
serhiy-storchaka:backport-3a1b547-3.14

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Manual backport of GH-153203 (the automatic backport could not apply: on 3.14 the code lives in Modules/mathmodule.c and the tests in Lib/test/test_math.py, predating the math.integer module).

The final check-and-correct comparison in the arbitrary precision path could call a comparison operator overridden in an int subclass. Compare by value with int's tp_richcompare.

(cherry picked from commit 3a1b547)

🤖 Generated with Claude Code

…ridden comparison operators (pythonGH-153203)

The final check-and-correct comparison in the arbitrary precision path
could call a comparison operator overridden in an int subclass.
Compare by value with int's tp_richcompare.

(cherry picked from commit 3a1b547)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jul 6, 2026

Copy link
Copy Markdown

GH-153226 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jul 6, 2026
serhiy-storchaka added a commit that referenced this pull request Jul 6, 2026
… comparison operators (GH-153203) (GH-153225) (GH-153226)

The final check-and-correct comparison in the arbitrary precision path
could call a comparison operator overridden in an int subclass.
Compare by value with int's tp_richcompare.

(cherry picked from commit 3a1b547)
(cherry picked from commit a9a91d0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant