From 42a39614f26a8bdc3f176ce47c506f2a99b5cf53 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 27 Apr 2026 08:05:02 +0000 Subject: [PATCH] fix: remove stray debug print calls in production code paths - 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 --- PyPtt/PTT.py | 1 - PyPtt/_api_util.py | 4 ++-- PyPtt/connect_core.py | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/PyPtt/PTT.py b/PyPtt/PTT.py index 1076ca79..35ba8220 100644 --- a/PyPtt/PTT.py +++ b/PyPtt/PTT.py @@ -99,7 +99,6 @@ def __init__(self, **kwargs): self.config.language = language - print('language', self.config.language) i18n.init(self.config.language) self.is_mailbox_full: bool = False diff --git a/PyPtt/_api_util.py b/PyPtt/_api_util.py index 59ddeab0..2cc810fb 100644 --- a/PyPtt/_api_util.py +++ b/PyPtt/_api_util.py @@ -218,8 +218,8 @@ def parse_query_post(api, ori_screen): cursor_line = [line for line in ori_screen.split( '\n') if line.strip().startswith(api.cursor)][0] except Exception as e: - print(api.cursor) - print(ori_screen) + log.logger.debug('cursor', api.cursor) + log.logger.debug('ori_screen', ori_screen) raise e post_author = cursor_line diff --git a/PyPtt/connect_core.py b/PyPtt/connect_core.py index a4abaa26..6ac973bd 100644 --- a/PyPtt/connect_core.py +++ b/PyPtt/connect_core.py @@ -185,7 +185,7 @@ def _wait(): connect_success = True except Exception as e: traceback.print_tb(e.__traceback__) - print(e) + log.logger.debug(str(e)) if self.config.host == data_type.HOST.PTT1: log.logger.info(i18n.connect, i18n.PTT, i18n.fail) @@ -286,7 +286,7 @@ def send(self, msg: str, target_list: list, screen_timeout: int = 0, refresh: bo pass except Exception as e: traceback.print_tb(e.__traceback__) - print(e) + log.logger.debug(str(e)) msg = msg.encode('utf-8', 'replace') if is_secret: