From b649c79924ce9384f8bff5fcb2970f72190a0300 Mon Sep 17 00:00:00 2001 From: M1nd3r Date: Wed, 16 Apr 2025 13:56:30 +0200 Subject: [PATCH] fix(core): remove calls to log on non-debug builds --- core/src/trezor/wire/thp/channel.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/core/src/trezor/wire/thp/channel.py b/core/src/trezor/wire/thp/channel.py index b11cd059c6..01f7eb02b7 100644 --- a/core/src/trezor/wire/thp/channel.py +++ b/core/src/trezor/wire/thp/channel.py @@ -183,12 +183,13 @@ class Channel: return received_message_handler.handle_received_message(self, buffer) elif self.expected_payload_length + INIT_HEADER_LENGTH > self.bytes_read: self.is_cont_packet_expected = True - self._log( - "CONT EXPECTED - read/expected:", - str(self.bytes_read) - + "/" - + str(self.expected_payload_length + INIT_HEADER_LENGTH), - ) + if __debug__ and utils.ALLOW_DEBUG_MESSAGES: + self._log( + "CONT EXPECTED - read/expected:", + str(self.bytes_read) + + "/" + + str(self.expected_payload_length + INIT_HEADER_LENGTH), + ) else: raise ThpError( "Read more bytes than is the expected length of the message!" @@ -238,7 +239,8 @@ class Channel: raise Exception( "Channel is in a state that does not support fallback." ) - self._log("Started fallback read") + if __debug__ and utils.ALLOW_DEBUG_MESSAGES: + self._log("Started fallback read") self._prepare_fallback() except Exception: self.fallback_decrypt = False @@ -385,7 +387,8 @@ class Channel: def _finish_fallback(self) -> None: self.fallback_decrypt = False self.busy_decoder = None - self._log("Finish fallback") + if __debug__ and utils.ALLOW_DEBUG_MESSAGES: + self._log("Finish fallback") def _decrypt_single_packet_payload( self, payload: utils.BufferType