[Python-Dev] dict contains raises TypeError on unhashable input (original) (raw)
Ethan Furman ethan at stoneleaf.us
Sat Jul 20 01:47:36 CEST 2013
- Previous message: [Python-Dev] Fwd: Issue 1229 in nativeclient: Get Python to work under Native Client
- Next message: [Python-Dev] dict __contains__ raises TypeError on unhashable input
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
While working on issue #18508 I stumbled across this:
Traceback (most recent call last): ... File "/usr/local/lib/python3.4/enum.py", line 417, in new if value in cls._value2member_map: TypeError: unhashable type: 'list'
I'll wrap it in a try-except block, but I must admit I was surprised the answer wasn't False. After all, if the input is unhashable then obviously it's not in the dict; furthermore, if I were to compare the number 5 with a set() I would get False, not a TypeMismatch error, and dict keys are basically done by equality, the hash is just (?) a speed-up.
--
Ethan
- Previous message: [Python-Dev] Fwd: Issue 1229 in nativeclient: Get Python to work under Native Client
- Next message: [Python-Dev] dict __contains__ raises TypeError on unhashable input
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]