Repository navigation
Preserve synchronous sorted iteration and comparison errors - #232
Closed
Apeksha9389 wants to merge 1 commit into
Closed
Apeksha9389 wants to merge 1 commit into
Apeksha9389 wants to merge 1 commit into
Conversation
1 task done
Author
|
Could a maintainer approve the pending CI runs and review this PR for merging? Local tests, Flake8, Black, MyPy, and PyRight all pass. Thank you. |
Owner
|
See #230 (comment) |
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.
This PR fixes
sorted()silently returning[]when a synchronous iterator raisesTypeErrorduring iteration or comparison. For example,await sorted(iter([1, "two"]))currently consumes the iterator, catches the comparison error, retries the exhausted iterator as async input, and returns an empty result.Select the synchronous fast path based on the iterable interface instead of catching every
TypeErrorfrom the entire sort. Async input still uses the existing materialization path, including synchronous sequence-protocol objects without__iter__.Three new regression cases fail on master and pass here. They cover both sort directions for incomparable values and an iterator that raises
TypeErroritself. A positive control covers indexed sequences.Validation on Python 3.12: 406 tests pass. Repository-wide Flake8, Black, MyPy and PyRight pass. Other interpreter versions are left to CI.
Prepared with AI assistance; reproduced and tested locally.
Closes #236