修复:替换 frontends 中 stapp.py 和 stapp2.py 的裸 except 子句#540
Open
Kailigithub wants to merge 1 commit into
Open
Conversation
将 `except: pass` 替换为 `except Exception: pass`,符合 Python 最佳实践, 避免捕获系统退出异常(KeyboardInterrupt、SystemExit),确保程序在重新配置 stdout/stderr 失败时仍能正常退出。
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.
Summary
替换
frontends/stapp.py和frontends/stapp2.py中的裸except:子句为except Exception: pass。Changes
frontends/stapp.pyL7-9:两处except: pass→except Exception: passfrontends/stapp2.pyL6-8:两处except: pass→except Exception: passVerification
ruff check --select E722通过,无 E722 错误python3 -m py_compile语法检查通过Rationale
裸
except:会捕获所有异常,包括SystemExit和KeyboardInterrupt,导致程序在配置 stdout/stderr 失败时无法正常退出。except Exception:仅捕获程序可处理的异常,符合 Python PEP 8 规范。