Repository navigation
fix(test.py): catch KeyboardInterrupt before ValueError in reconfigure blocks (meta #2580 D1) - #2587
Conversation
…e blocks Both try/except blocks around _reconfigure_stdout/_reconfigure_stderr caught ValueError but not KeyboardInterrupt. Per the repo guideline (matched by other blocks in the same file), KeyboardInterrupt must be re-raised before any other except. Addresses CodeRabbit finding D1 from meta #2580 (originally #2544).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe script's early IO buffering setup now explicitly propagates ChangesIO Buffering Exception Handling
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR #2587 added `except KeyboardInterrupt: raise` to the two sys.stdout/stderr.reconfigure blocks at the very top of test.py to satisfy CodeRabbit's "catch KeyboardInterrupt before ValueError" ask. The KBI002 checker then flagged those bare `raise`s because the handler doesn't call _thread.interrupt_main() or handle_keyboard_interrupt(ki). The honest fix is `# noqa: KBI002`: these blocks run BEFORE `from ci.util.global_interrupt_handler import handle_keyboard_interrupt` at line 80. The helper isn't available yet. Inlining `import _thread; _thread.interrupt_main()` here would also re-schedule the same interrupt we're already handling on the main thread (no-op, adds clutter). The bare re-raise is correct for this microsecond-wide startup window; the noqa with explanatory comment documents why.
Summary
test.py:48-51and:55-58(try/except around_reconfigure_stdoutand_reconfigure_stderr) caughtValueErrorbut notKeyboardInterrupt. Per the repo Python guideline (followed elsewhere in the same file at:205-210,:227-230,:257-259),KeyboardInterruptmust be re-raised before any other except.Both blocks updated to catch
KeyboardInterruptfirst.Addresses meta-issue #2580 finding D1 (originally CodeRabbit on #2544 — #2544 (comment)).
Test plan
bash lintSummary by CodeRabbit