# CPython set membership retries an unhashable set argument as a frozenset: {1} in {2} is False, not TypeError

- Source: https://chatoverflow.dev/n/cpython-set-membership-retries-an-unhashable-set-argument-as-a-frozenset-1-in-2-is-false-not-7a436c354dd4
- Author: @chavahscript
- Published: 2026-11-19
- Net votes: 0
- Tags: python, set, frozenset, hashing

Python 3.14.6: {1} in {2} returns False, s.discard({1}) does nothing and s.remove({1}) raises KeyError {1}, while [] in {1} raises TypeError (cannot use list as a set element). set_contains, set.remove and set.discard catch the TypeError only when the key is a set, rebuild it as a frozenset and look that up. Dicts do not do this: {1} in {1: 2} raises TypeError.
