fix: remove stray debug print calls in production code paths#1
Open
PttCodingMan wants to merge 1 commit intomasterfrom
Open
fix: remove stray debug print calls in production code paths#1PttCodingMan wants to merge 1 commit intomasterfrom
PttCodingMan wants to merge 1 commit intomasterfrom
Conversation
- PTT.py: drop `print('language', ...)` in API.__init__; the language
is already reported via `log.logger.info(i18n.set_up_lang_module, ...)`
later in the init flow.
- _api_util.py: replace debug `print(api.cursor)` / `print(ori_screen)`
in parse_query_post's except block with `log.logger.debug(...)` so the
diagnostics are gated by log level.
- connect_core.py: replace `print(e)` after `traceback.print_tb(...)` in
both the connect and send_msg except blocks with `log.logger.debug(...)`.
No behavior change at default log level beyond removing the unconditional
"language Mandarin" line that leaked to stdout on every API() init.
https://claude.ai/code/session_018UnF3J7NAA125VrQTreYKf
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
清掉混進生產程式碼裡的三處
printdebug 殘留,全部改走既有的log.logger通道,使用者的 stdout 不再被噪訊污染。PTT.py:102—print('language', self.config.language)直接刪除。語言設定原本就會在 init 流程後段透過log.logger.info(i18n.set_up_lang_module, ...)(PTT.py:167-169)正確記錄,這行純粹是 debug 殘留。_api_util.py:221-222—parse_query_post的except區塊裡的print(api.cursor)/print(ori_screen)改成log.logger.debug(...),受 log level 控管。connect_core.py:188, 289— 連線與send_msg兩處except裡的print(e)(緊跟在traceback.print_tb(...)後)改成log.logger.debug(str(e))。Why
每次
PyPtt.API()初始化時,stdout 都會跳出一行language Language.MANDARIN,這對函式庫使用者是純干擾——尤其是把 PyPtt 包進更大的 CLI 或 service 時。其他兩處的print同樣繞過了專案自己定義的log.logger,破壞了 log level 的一致性。Test plan
python -m py_compile三個改動檔案皆通過python -c "import PyPtt; PyPtt.API(language=PyPtt.Language.MANDARIN)"smoke test:stdout 不再有language ...噪訊,logger 仍正確輸出[INFO] 設定語言模組 ... 繁體中文connect_core.py兩處 except)需要實際斷線情境驗證;目前僅靠 logger 通道的等價性靜態判斷python tests/init.pyNotes
範圍刻意控制在「真 debug 殘留」三處。以下
print經檢查是合理用途,未動:PTT.py:229-235—login()docstring 裡的範例::code blockPTT.py:1064-1065—if __name__ == '__main__':CLI 版本資訊輸出service.py:35,38,41—Servicedocstring 裡的範例::code blockscreens.py:165-191(show()) — DEBUG-only 螢幕視覺化函式,本身就是 debug 工具screens.py:354、check_value.py:60-70—__main__block 裡的手動測試https://claude.ai/code/session_018UnF3J7NAA125VrQTreYKf
Generated by Claude Code