Skip to content

gh-148268: Avoid debug assertion in specialized list compares#148309

Open
officialasishkumar wants to merge 2 commits into
python:mainfrom
officialasishkumar:gh-148268-list-sort-debug-assert
Open

gh-148268: Avoid debug assertion in specialized list compares#148309
officialasishkumar wants to merge 2 commits into
python:mainfrom
officialasishkumar:gh-148268-list-sort-debug-assert

Conversation

@officialasishkumar

Copy link
Copy Markdown

Handle recursion errors raised by the debug-only cross-check in the specialized latin, compact-int, and float comparison helpers used by list sorting. When that verification path hits the C stack overflow guard, clear the resulting exception so the optimized comparison remains side-effect free.

I did not add a targeted regression test because the failure is in a debug-only verification path that is only triggered when the extra PyObject_RichCompareBool() call hits the C stack guard; I could not produce a stable Python-level reproducer for that condition.

Tests:

  • ./python -m test -j1 test_sort test_richcmp

Handle recursion errors raised by the debug-only cross-check in the specialized latin, compact-int, and float comparison helpers used by list sorting. When the verification path hits the C stack overflow guard, clear that exception so the optimized comparison remains side-effect free.\n\nThe change preserves the consistency assertion when the fallback comparison succeeds and adds a NEWS entry for the fix.
@python-cla-bot

python-cla-bot Bot commented Apr 9, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@tim-one tim-one left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Ship it 😄

@StanFromIreland

Copy link
Copy Markdown
Member

@officialasishkumar you'll need to sign the CLA, see #148309 (comment).

@officialasishkumar

Copy link
Copy Markdown
Author

Done

@officialasishkumar

Copy link
Copy Markdown
Author

Signed the cla

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants