Skip to content

Conversation

@Abdoulrasheed
Copy link
Contributor

@Abdoulrasheed Abdoulrasheed commented Dec 17, 2025

This fix holds strong references to the HAMT objects and their keys/values during comparison in _PyHamt_Eq, preventing premature deallocation.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what we commonly do to solve such issues.

@kumaraditya303
Copy link
Contributor

Can you add a test which does the same but with __hash__? I suspect that has the same issue.

@Abdoulrasheed
Copy link
Contributor Author

Can you add a test which does the same but with __hash__? I suspect that has the same issue.

@kumaraditya303 I think __hash__ on values isn't called during Context comparison. only keys are hashed, and ContextVar uses a pre-computed hash. But I've added a test for it just to be safe.

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.

3 participants