-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Description
Bug report
Exceptions thrown into a generator multiple times have multiple tracebacks which can lead to unbounded growth of exceptions.
It's not clear to me if this an issue or working as designed honestly. I do find the behavior to be unexpected.
Exceptions which persist across multiple calls to generator.throw accumulate stack frames inside of their __traceback__ object. This can lead to unbounded object growth if the exception is particularly long lived and frequently used (see twisted/twisted#11874 for an example).
Failing unit test displaying this behavior. One would expect the exception to have 2 stack frames but instead it has 3 (2 from line 14 and one from line 6).
https://gist.github.com/mbish/25f67b0e56d944103108fbc515b0f821
Your environment
Linux 6.3.6-arch1-1 twisted/twisted#1 SMP PREEMPT_DYNAMIC Mon, 05 Jun 2023 15:12:57 +0000 x86_64 GNU/Linux
DISTRIB_ID="Arch"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="Arch Linux"
- CPython versions tested on: Python 3.11.3
- Operating system and architecture: