autotest: correct exception handling for Python 3.10

This commit is contained in:
Peter Barker 2022-03-07 12:45:19 +11:00 committed by Peter Barker
parent 7e7da560d5
commit f2fe55b5da
2 changed files with 8 additions and 4 deletions

View File

@ -6558,10 +6558,12 @@ Also, ignores heartbeats not from our target system'''
def get_exception_stacktrace(self, e):
if sys.version_info[0] >= 3:
ret = "%s\n" % e
ret += ''.join(traceback.format_exception(etype=type(e),
value=e,
ret += ''.join(traceback.format_exception(type(e),
e,
tb=e.__traceback__))
return ret
# Python2:
return traceback.format_exc(e)
def bin_logs(self):

View File

@ -527,10 +527,12 @@ is bob we will attempt to checkout bob-AVR'''
def get_exception_stacktrace(self, e):
if sys.version_info[0] >= 3:
ret = "%s\n" % e
ret += ''.join(traceback.format_exception(etype=type(e),
value=e,
ret += ''.join(traceback.format_exception(type(e),
e,
tb=e.__traceback__))
return ret
# Python2:
return traceback.format_exc(e)
def print_exception_caught(self, e, send_statustext=True):