Always raise TypeError for wrong argument types

The code that checks whether hooks are callable() (and some other type
checks) should always raise TypeError on failure. Before this change,
both ValueError and TypeError were used in an inconsistent way (C
extension and Python implementation were not the same).