def _raise_typecheck_error(msg, is_return=False, value=None, received_type=None,
expected_type=None, func=None):
if pytypes.warning_mode:
import traceback
tb = traceback.extract_stack()
off = util._calc_traceback_list_offset(tb)
cat = pytypes.ReturnTypeWarning if is_return else pytypes.InputTypeWarning
warn_explicit(msg, cat, tb[off][0], tb[off][1])
# if not func is None:
# warn_explicit(msg, cat, func.__code__.co_filename,
# func.__code__.co_firstlineno, func.__module__)
# else:
# warn(msg, pytypes.ReturnTypeWarning)
else:
if is_return:
raise pytypes.ReturnTypeError(msg)
else:
raise pytypes.InputTypeError(msg)
评论列表
文章目录