Skip to content

Conversation

@kemingy
Copy link

@kemingy kemingy commented Nov 27, 2025

gh-141805: goes directly to the found_unused_or_dummy when finding a dummy slot in set.add

This avoids triggering the __eq__ in the next iteration by the PyObject_RichCompareBool, which might introduce another set.add in the user code. Like:

tasks = set()

class Corrupt:
    def __eq__(self, value):
        tasks.add(self)
        return False

As described in #141805 (comment)

…er add

Signed-off-by: Keming <kemingy94@gmail.com>
@kemingy kemingy requested a review from rhettinger as a code owner November 27, 2025 09:52
@kemingy kemingy changed the title fix: avoid increase the set->used twice when the __eq__ trigger another add gh-141805: avoid increase the set->used twice when the __eq__ trigger another add Nov 27, 2025
Signed-off-by: Keming <kemingy94@gmail.com>
Signed-off-by: Keming <kemingy94@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants