[New-bugs-announce] [issue45924] Incorrect traceback when future's exception is raised multiple times
Irit Katriel
report at bugs.python.org
Mon Nov 29 06:55:26 EST 2021
New submission from Irit Katriel <iritkatriel at gmail.com>:
Background:
https://github.com/python/cpython/pull/29780#issuecomment-981170548
https://github.com/python/cpython/pull/29780#issuecomment-981260365
######################################################
import asyncio, traceback
async def raise_after(fut, delay):
await asyncio.sleep(delay)
fut.set_exception(TypeError(42))
async def main():
loop = asyncio.get_running_loop()
fut = loop.create_future()
loop.create_task(
raise_after(fut, 1))
print('hello ...')
for i in range(3):
try:
print(await fut)
except Exception as e:
traceback.print_exception(e)
asyncio.run(main())
######################################################
Output (traceback accumulates a frame each time):
hello ...
Traceback (most recent call last):
File "/Users/iritkatriel/src/cpython-1/as.py", line 17, in main
print(await fut)
^^^^^^^^^
TypeError: 42
Traceback (most recent call last):
File "/Users/iritkatriel/src/cpython-1/as.py", line 17, in main
print(await fut)
^^^^^^^^^
File "/Users/iritkatriel/src/cpython-1/as.py", line 17, in main
print(await fut)
^^^^^^^^^
TypeError: 42
Traceback (most recent call last):
File "/Users/iritkatriel/src/cpython-1/as.py", line 17, in main
print(await fut)
^^^^^^^^^
File "/Users/iritkatriel/src/cpython-1/as.py", line 17, in main
print(await fut)
^^^^^^^^^
File "/Users/iritkatriel/src/cpython-1/as.py", line 17, in main
print(await fut)
^^^^^^^^^
TypeError: 42
----------
components: asyncio
messages: 407265
nosy: asvetlov, gvanrossum, iritkatriel, yselivanov
priority: normal
severity: normal
status: open
title: Incorrect traceback when future's exception is raised multiple times
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45924>
_______________________________________
More information about the New-bugs-announce
mailing list