I think you should just except for the `TypeError` class of exception that is raised for un-hashable objects passed as keys for a dict.