Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Refactor output stream handling to use try-finally for restoration.
Added tests for runner functionality and error handling.
Added a new entry for the unreleased changes and fixed the output streams restoration note.
- main() 结束后恢复调用者的 logging 禁用级别(之前会永久关闭 CRITICAL 以下日志) - NullWriter 增加 flush()/isatty(),避免被静默的第三方库调用时 AttributeError - 注释说明必须恢复调用者安装的流而不能再写回 sys.__stdout__/__stderr__ - CHANGELOG 条目并入已有的 Unreleased 段并改为中文,补充 mozillazg#384 链接 - 测试用 fixture 消除重复的 setup,并断言 logging 状态被恢复
mozillazg
force-pushed
the
fix/runner-stream-restoration-develop
branch
from
November 22, 2026 13:28
ed149d2 to
24a1e74
Compare
mozillazg
approved these changes
Nov 22, 2026
mozillazg
left a comment
Owner
There was a problem hiding this comment.
LGTM, Thanks for your contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 描述
The runner temporarily silences stdout/stderr while invoking converters. On success it currently restores
sys.__stdout__/sys.__stderr__rather than the streams the caller installed. If conversion raises, both streams remain replaced byNullWriter, so later diagnostics disappear.Save the original caller streams and restore them in
finallybefore printing converted results or propagating an exception. Add success cases for pinyin/slug and failure cases forValueError/KeyboardInterrupt, checking exact stream identity, output suppression and exception identity. Add an Unreleased changelog entry.Validation:
pytest -sand empty stdin, matching the project's capture-disabled configuration. Existing toneconvert tests read stdin and fail under pytest's default capture.git diff --checkpass.Logging-state behavior is unchanged. This does not make process-global output redirection thread-safe. No Python 2, Windows or remote CI result is claimed. Targeting
developas requested by the PR template.待办事项