Explain an exception.
(start=-1, stop=None, prefix="> ")
| 24 | |
| 25 | |
| 26 | def _explain_exception(start=-1, stop=None, prefix="> "): |
| 27 | """Explain an exception.""" |
| 28 | # start=-1 means "only the most recent caller" |
| 29 | etype, value, tb = sys.exc_info() |
| 30 | string = traceback.format_list(traceback.extract_tb(tb)[start:stop]) |
| 31 | string = "".join(string).split("\n") + traceback.format_exception_only(etype, value) |
| 32 | string = ":\n" + prefix + ("\n" + prefix).join(string) |
| 33 | return string |
| 34 | |
| 35 | |
| 36 | class _TempDir(str): |