mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 05:20:49 -05:00
This fixes #15317. Our `catch_unwind` wrapper installs a panic hook that captures (the rendered contents of) the panic info when a panic occurs. Since the intent is that the caller will render the panic info in some custom way, the hook silences the default stderr panic output. However, the panic hook is a global resource, so if any one thread was in the middle of a `catch_unwind` call, we would silence the default panic output for _all_ threads. The solution is to also keep a thread local that indicates whether the current thread is in the middle of our `catch_unwind`, and to fall back on the default panic hook if not. ## Test Plan Artificially added an mdtest parse error, ran tests via `cargo test -p red_knot_python_semantic` to run a large number of tests in parallel. Before this patch, the panic message was swallowed as reported in #15317. After, the panic message was shown.