Raise TypeError instead of AssertionError.
Merge pull request #937 from lepture/fix-assert

Raise TypeError instead of AssertionError.