Created
October 16, 2025 19:13
-
-
Save quis/e58c10d67ad58a94f4beb34770778883 to your computer and use it in GitHub Desktop.
Proof of concept for user sorting bug
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
| class User(): | |
| def __lt__(self, other): | |
| return False | |
| def __eq__(self, other): | |
| return self.foo == other.foo | |
| # Replicates https://github.com/pallets/jinja/blob/5ef70112a1ff19c05324ff889dd30405b1002044/src/jinja2/filters.py#L435-L437 | |
| def key_func(user): | |
| return [user] | |
| users = [User(), User()] | |
| # This passes | |
| print(sorted(users)) | |
| # This raises on 3.11 and 3.13, but I’d expect it to pass on 3.11 | |
| print(sorted(users, key=key_func)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment