Raise TypeError instead of AssertionError.

This is a type checking, it should raise TypeError instead of AssertionError.

https://mail.python.org/pipermail/python-list/2013-November/660401.html