Skip to content

fix(test.py): catch KeyboardInterrupt before ValueError in reconfigure blocks (meta #2580 D1) - #2587

Merged
zackees merged 1 commit into
masterfrom
fix/2580-testpy-keyboardinterrupt
May 30, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/2580-testpy-keyboardinterrupt

Conversation

@zackees

@zackees zackees commented May 30, 2026 •

Copy link
Copy Markdown
Member

Summary

test.py:48-51 and :55-58 (try/except around _reconfigure_stdout and _reconfigure_stderr) caught ValueError but not KeyboardInterrupt. Per the repo Python guideline (followed elsewhere in the same file at :205-210, :227-230, :257-259), KeyboardInterrupt must be re-raised before any other except.

Both blocks updated to catch KeyboardInterrupt first.

Addresses meta-issue #2580 finding D1 (originally CodeRabbit on #2544 — #2544 (comment)).

Test plan

  • bash lint
  • CI green

Summary by CodeRabbit

  • Bug Fixes
    • Fixed keyboard interrupt handling to ensure Ctrl+C works properly during startup IO configuration.

Review Change Stack

…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).
@coderabbitai

coderabbitai Bot commented May 30, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 151d588d-4ef4-4f00-ab8d-f1e63627d631

📥 Commits

Reviewing files that changed from the base of the PR and between 9cb8566 and 0682bdd.

📒 Files selected for processing (1)
  • test.py

📝 Walkthrough

Walkthrough

The script's early IO buffering setup now explicitly propagates KeyboardInterrupt exceptions during stdout and stderr reconfiguration, while continuing to suppress ValueError exceptions. This ensures user interrupts (Ctrl+C) are not suppressed during buffering initialization.

Changes

IO Buffering Exception Handling

Layer / File(s) Summary
IO buffering exception handling
test.py
The stdout and stderr non-TTY reconfigure(line_buffering=True) blocks add explicit except KeyboardInterrupt: raise handlers before catching ValueError, ensuring keyboard interrupts propagate during setup while maintaining existing ValueError suppression.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • FastLED/FastLED#2544: Both PRs modify test.py's stdout/stderr reconfigure(line_buffering=True) exception handling, with the related PR suppressing ValueError and this PR adding explicit KeyboardInterrupt re-raising.

Poem

🐰 Ctrl+C must flow, no buffering delay,
Interrupts skip the exception's sway,
KeyboardInterrupt now finds its way,
Through stdout and stderr's early display! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: catching KeyboardInterrupt before ValueError in reconfigure blocks in test.py, which matches the actual modifications to the try/except blocks.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/2580-testpy-keyboardinterrupt

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit 862697c into master May 30, 2026
3 of 4 checks passed
@zackees
zackees deleted the fix/2580-testpy-keyboardinterrupt branch May 30, 2026 15:28
zackees added a commit that referenced this pull request May 30, 2026
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.
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.

1 participant