def print_exception(exc):
"""
Prints the exception string to StdErr. XML tags are stripped.
"""
error_string = ""
if isinstance(exc, Exception):
if not isinstance(exc, NoTraceException):
_, _, error_string, _ = get_error_repr(sys.exc_info())
error_string = "TRACE:\n{}".format(error_string)
error_string += "ERROR {}: {}\n".format(type(exc).__name__, exc)
else:
error_string = exc
for par in [x.strip(" ") for x in error_string.split("</p>") if x.strip(" ")]:
par = par.replace("\n", " ").strip(" ")
par = par.replace(" ", " ")
print("\n".join(
textwrap.wrap(re.sub('<[^>]*>', '', par), width=70, replace_whitespace=False)),
file=sys.stderr)
print(file=sys.stderr)
评论列表
文章目录