When an argument is invalid, use TypeError, not AttributeError.