gh-117459: Keep the traceback in _convert_future_exc (#117460)

This commit is contained in:
rsp4jack 2024-04-04 11:13:32 +08:00 committed by GitHub
parent b4fe02f595
commit 85843348c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 4 deletions

View file

@ -319,11 +319,9 @@ def _set_result_unless_cancelled(fut, result):
def _convert_future_exc(exc):
exc_class = type(exc)
if exc_class is concurrent.futures.CancelledError:
return exceptions.CancelledError(*exc.args)
elif exc_class is concurrent.futures.TimeoutError:
return exceptions.TimeoutError(*exc.args)
return exceptions.CancelledError(*exc.args).with_traceback(exc.__traceback__)
elif exc_class is concurrent.futures.InvalidStateError:
return exceptions.InvalidStateError(*exc.args)
return exceptions.InvalidStateError(*exc.args).with_traceback(exc.__traceback__)
else:
return exc