Skip to content

Preserve the final output when interactive code exits - #1066

Open
Boulea7 wants to merge 1 commit into
bpython:mainfrom
Boulea7:fix/745-preserve-exit-output
Open

Boulea7 wants to merge 1 commit into
bpython:mainfrom
Boulea7:fix/745-preserve-exit-output

Conversation

@Boulea7

@Boulea7 Boulea7 commented Dec 3, 2026

Copy link
Copy Markdown

Fixes #745

The final repaint after SystemExit replaced the last output row with a second copy of the command. For argparse, the usage line survived and the error explaining the missing argument disappeared.

The exit frame now keeps the command and its completed output in history, then paints any pending output and leaves the cursor after it.

  • Verified the original argparse example in real PTYs against bpython 0.26, main, and CPython. The error stays visible, the command appears once, and the exit status remains 2.
  • Added screen regressions for the diagnostic, zero-width output, and pending output longer than a screen. The full suite reported 346 passed, 8 skipped, and 3 expected failures. Ruff and git diff --check passed.

The verification uses the bpython console script. The module launcher currently exits 1 for the same exception. A separate stress case with repeated decomposed Unicode can fail in the live renderer before the exit frame.

Assisted-by: Codex

@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.23%. Comparing base (1a919d3) to head (bab5ac2).
⚠️ Report is 88 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1066      +/-   ##
==========================================
- Coverage   76.51%   76.23%   -0.29%     
==========================================
  Files          62       60       -2     
  Lines        8308     8618     +310     
==========================================
+ Hits         6357     6570     +213     
- Misses       1951     2048      +97     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

bpython quits when parsing empty arguments with argparse module

1 participant