Skip to content

Instantly share code, notes, and snippets.

@quis
Created October 16, 2025 19:13
Show Gist options
  • Select an option

  • Save quis/e58c10d67ad58a94f4beb34770778883 to your computer and use it in GitHub Desktop.

Select an option

Save quis/e58c10d67ad58a94f4beb34770778883 to your computer and use it in GitHub Desktop.
Proof of concept for user sorting bug
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