Skip to content

fix(issue #3279): More traceback cleaning - #3498

Open
arunsoman wants to merge 2 commits into
python-trio:mainfrom
arunsoman:forge/fix-issue-3279
Open

fix(issue #3279): More traceback cleaning#3498
arunsoman wants to merge 2 commits into
python-trio:mainfrom
arunsoman:forge/fix-issue-3279

Conversation

@arunsoman

Copy link
Copy Markdown

Fixes #3279

What

autonomous fix via atomic-forge fix — CIE (code graph over MCP) localized the bug, generated a failing regression test, and forge's repair loop fixed the source against it.

Issue

More traceback cleaning

https://vorpus.org/blog/beautiful-tracebacks-in-trio-v070/ made tracebacks in some scenarios nicer, but afaict it mostly just affects calls to trio.run and when spawning tasks. (Implementation. Tested in test_traceback_frame_removal).

But there's still a lot of other scenarios that cause verbose outputs:

import trio
import trio.testing

cl = trio.CapacityLimiter(1)
async def borrower() -> None:
    await cl.acquire()
    await trio.sleep_forever()

async def main() -> None:
    async with trio.open_nursery() as nursery:
        nursery.start_soon(borrower)
        await trio.testing.wait_all_tasks_blocked()

        with trio.fail_after(1):
            async with cl:
                pass
trio.run(main)
  + Exception Group Traceback (most recent call last):
  |   File "/home/h/Git/trio/clean_tb/test_foo.py", line 16, in <module>
  |     trio.run(main)
  |     ~~~~~~~~^^^^^^
  |   File "/home/h/Git/trio/clean_tb/src/trio/_core/_run.py", line 2529, in run
  |     raise runner.main_task_outcome.error
  |   File "/home/h/Git/trio/clean_tb/test_foo.py", line 10, in main
  |     async with trio.open_nursery() as nursery:
  |                ~~~~~~~~~~~~~~~~~^^
  |   File "/home/h/Git/trio/clean_tb/src/trio/_core/_run.py", line 1122, in __aexit__
  |     raise combined_error_from_nursery
  | ExceptionGroup: Exceptions from Trio nursery (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/home/h/Git/trio/clean_tb/src/trio/_sync.py", line 342, in acquire_on_behalf_of
    |     self.acquire_on_behalf_of_nowait(borrower)
    |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
    |   File "/home/h/Git/trio/clean_tb/src/trio/_sync.py", line 312, in acquire_on

## How it was verified
- regression test: `tests/test_forge_3279.py` (CIE-generated; fails on the pre-fix code, passes on the fix)
- repair rounds: 2  failures: 1 -> 0
- repaired file(s): src/trio/_core/_run.py

---
<!-- atomic-forge:pr -->
[![Fixed by Forge](https://img.shields.io/badge/fixed_by-atomic--forge-6f42c1?logo=github)](https://github.com/kannamma-labs/atomic-forge)

🔨 Fixed by [Forge](https://github.com/kannamma-labs/atomic-forge) — an autonomous, test-driven issue→PR repair engine (`atomic-forge fix <issue-url>`).

⭐ If you found this useful, a star on [atomic-forge](https://github.com/kannamma-labs/atomic-forge) helps other maintainers find the tool that fixed your bug.

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 99.99486%. Comparing base (d5eb534) to head (e863d33).

Files with missing lines Patch % Lines
src/trio/_core/_run.py 50.00000% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##                 main       #3498         +/-   ##
====================================================
- Coverage   100.00000%   99.99486%   -0.00514%     
====================================================
  Files             128         128                 
  Lines           19452       19454          +2     
  Branches         1321        1322          +1     
====================================================
+ Hits            19452       19453          +1     
- Partials            0           1          +1     
Files with missing lines Coverage Δ
src/trio/_core/_run.py 99.90530% <50.00000%> (-0.09471%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More traceback cleaning

1 participant