Merge pull request #26637 from blaggacao/feat/error-reraise

This commit is contained in:
Suraj Shetty 2024-06-21 16:43:19 +05:30 committed by GitHub
commit 4c1b858810
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -296,16 +296,18 @@ def get_traceback(with_context=False) -> str:
"""Return the traceback of the Exception."""
from traceback_with_variables import iter_exc_lines
exc_type, exc_value, exc_tb = sys.exc_info()
if not any([exc_type, exc_value, exc_tb]):
exc = sys.exception()
if not exc:
return ""
if exc.__cause__:
exc = exc.__cause__
if with_context:
trace_list = iter_exc_lines(fmt=_get_traceback_sanitizer())
trace_list = iter_exc_lines(exc, fmt=_get_traceback_sanitizer())
tb = "\n".join(trace_list)
else:
trace_list = traceback.format_exception(exc_type, exc_value, exc_tb)
trace_list = traceback.format_exception(exc)
tb = "".join(cstr(t) for t in trace_list)
bench_path = get_bench_path() + "/"