Skip to content

Commit d9f4834

Browse files
sampsoncclaude
andcommitted
gh-145678: Guard against re-entrant __eq__ never being called
Add assertIsNotNone check so the test fails explicitly if the re-entrant code path is never triggered, rather than passing vacuously. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 750b54a commit d9f4834

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Lib/test/test_itertools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ def __hash__(self):
780780
g = itertools.groupby([1, 1, 2], lambda _: next(keys_iter))
781781
k, grp = next(g)
782782
list(grp) # must not crash with address sanitizer
783+
self.assertIsNotNone(ref_before, "re-entrant __eq__ was never called")
783784
# On an unpatched build, next(g) releases gbo->currkey's reference to
784785
# 'other', so the count drops by 1 -- the object will be freed when the
785786
# __eq__ frame exits, leaving do_richcompare() with a dangling pointer.

0 commit comments

Comments
 (0)