summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-07-11 14:38:27 (GMT)
committerGitHub <noreply@github.com>2022-07-11 14:38:27 (GMT)
commitaa2142def669e87016406acf7a84a5254487b0ee (patch)
treeca8a2786dcb521e633dc6a249e48796b015e8381 /Lib/asyncio
parent916686fdb273d6adbd403e6d58029960ec7a89ab (diff)
downloadcpython-aa2142def669e87016406acf7a84a5254487b0ee.zip
cpython-aa2142def669e87016406acf7a84a5254487b0ee.tar.gz
cpython-aa2142def669e87016406acf7a84a5254487b0ee.tar.bz2
bpo-45924: Fix asyncio incorrect traceback when future's exception is raised multiple times (GH-30274) (#94748)
(cherry picked from commit 86c1df18727568758cc329baddc1836e45664023) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Lib/asyncio')
-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 8e8cd87..48a32f8 100644
--- a/Lib/asyncio/futures.py
+++ b/Lib/asyncio/futures.py
@@ -198,7 +198,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):
@@ -274,6 +274,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