Throwing into a not yet started async generator loses the original traceback
Author: typenoobCreated Oct 1, 2026Updated Oct 1, 2026
Bug Report
Bug Description
Throwing an exception into an async generator that has not been started yet drops the traceback the exception already had, so caught.__traceback__ contains only the frames produced by athrow() and not the frame that originally raised the exception. CPython preserves those pre-existing frames.
This breaks traceback-based diagnostics for libraries that re-throw a stored exception into a generator.
️ Environment
1. Nuitka Version, Python Version, OS, and Platform
Provide the full output of this command (replace python with your specific interpreter if
needed, e.g. python_t, for free-threading or python_d for debug Python):
uv run -m nuitka --version
4.3rc4
Update status: newer than stable release '4.2.2' (cached, 17 hours old).
Commercial: None
Python: 3.11.15 (main, Jun 11 2026, 04:59:07) [MSC v.1944 64 bit (AMD64)]
Flavor: Unknown
Executable: D:\code\vendor\nuitka\.venv\Scripts\python.exe
OS: Windows
Arch: x86_64
WindowsRelease: 11
Nuitka-Scons: Non downloaded winlibs-gcc 'D:\msys64\\\ucrt64\bin\gcc.exe' is being ignored, Nuitka
Nuitka-Scons: is very dependent on the precise one.
Version C compiler: gcc (gcc 15.2.0).2. How Nuitka and Python were Installed
UV
️ To Reproduce
import asyncio
import traceback
def make_exception():
try:
raise ValueError("original")
except ValueError as caught:
return caught
async def async_generator():
yield 1
def print_traceback(caught):
for frame in traceback.extract_tb(caught.__traceback__):
print(frame.lineno, frame.name)
async def main():
print("Throwing into a not started async generator:")
try:
await async_generator().athrow(make_exception())
except ValueError as caught:
print_traceback(caught)
asyncio.run(main())3. Nuitka Command Line Options
uv run -m nuitka main.pyExpected Behavior
The same as CPython printed out.
Throwing into a not started async generator:
26 main
12 async_generator
7 make_exceptionActual Behavior & Output
The original error is lost.
Throwing into a not started async generator:
25 main
11 async_generatorAdditional Context (Optional)
Discovered this when working on #4072
Source: Nuitka/Nuitka