If the object raised is not a legal Exception class or an instance of one, then a TypeError will be raised instead.

Legal exception classes are:

However, it recommended that you only use subclasses of the builtin class Exception (which is itself a subclass of BaseException).

Change the expression in the raise statement to be a legal exception.

  • Python Language Reference: Exceptions.
  • Python Tutorial: Handling Exceptions.