Skip to content

gh-153200: Fix math.isqrt() for int subclasses with overridden comparison operators#153203

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:fix/math/isqrt-index
Open

gh-153200: Fix math.isqrt() for int subclasses with overridden comparison operators#153203
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:fix/math/isqrt-index

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

The final check-and-correct comparison in the arbitrary precision path could call a comparison operator overridden in an int subclass, producing an off-by-one result for arguments not less than 2**64. Compare by value with int's tp_richcompare instead (same approach as PyDict_Type.tp_richcompare in Objects/odictobject.c).

🤖 Generated with Claude Code

…comparison operators

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.

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

awaiting core review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant