summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/futures.py
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-07-11 12:32:11 (GMT)
committerGitHub <noreply@github.com>2022-07-11 12:32:11 (GMT)
commit86c1df18727568758cc329baddc1836e45664023 (patch)
treefb1d5408dd0070b83e2df33030f38491a518634a /Lib/asyncio/futures.py
parentf5b76330cfb93e1ad1a77c71dafe719f6a808cec (diff)
downloadcpython-86c1df18727568758cc329baddc1836e45664023.zip
cpython-86c1df18727568758cc329baddc1836e45664023.tar.gz
cpython-86c1df18727568758cc329baddc1836e45664023.tar.bz2
bpo-45924: Fix asyncio incorrect traceback when future's exception is raised multiple times (GH-30274)
Diffstat (limited to 'Lib/asyncio/futures.py')
-rw-r--r--Lib/asyncio/futures.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/asyncio/futures.py b/Lib/asyncio/futures.py
index 08c79e7..4bd9629 100644
--- a/Lib/asyncio/futures.py
+++ b/Lib/asyncio/futures.py
@@ -206,7 +206,7 @@ class Future:
raise exceptions.InvalidStateError('Result is not ready.')
self.__log_traceback = False
if self._exception is not None:
- raise self._exception
+ raise self._exception.with_traceback(self._exception_tb)
return self._result
def exception(self):
@@ -282,6 +282,7 @@ class Future:
raise TypeError("StopIteration interacts badly with generators "
"and cannot be raised into a Future")
self._exception = exception
+ self._exception_tb = exception.__traceback__
self._state = _FINISHED
self.__schedule_callbacks()
self.__log_traceback = True