While trying to figure out why passing an unhashable object to switch didn't cause a TypeError: unhashable object, I found out PyDict_GetItem and dict_subscript behave differently in that respect. PyDict_GetItem does: hash = PyObject_Hash(key); if (hash == -1) { PyErr_Clear(); return NULL; } whereas dict_subscript does: hash = PyObject_Hash(key); if (hash == -1) return NULL; PyDict_SetItem and PyDict_DelItem both behave like dict_subscript (that is, they propagate the error upwards, instead of clearing the error.) Is this intentional ? Why ? :P And what is the 'right' way to do a PyDict_GetItem() that gives the proper error-message without relying on the need for that particular dict (which could be a subtype that has more or less restrictions) to have hashable keys ? -- Thomas Wouters <thomas@xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4