Skip to content

Commit 0293c6d

Browse files
thepastaclawclaude
andcommitted
fix: read governance debug log tail in binary mode
feature_governance_cl.py was opening debug.log in text mode but seeking with a binary offset. The fully safe fix is to read the tail in binary mode, seek using a binary offset, then decode the resulting bytes afterward for the string match. This preserves the existing 100 KiB tail scan while avoiding invalid mixed-mode seek behavior in Python text I/O. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 67683f3 commit 0293c6d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

test/functional/feature_governance_cl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ def run_test(self):
147147
expected_msg = f'CGovernanceManager::UpdatedBlockTip -- nCachedBlockHeight: {tip_height}'
148148

149149
def governance_tip_updated(node):
150-
with open(node.debug_log_path, encoding='utf-8') as dl:
150+
with open(node.debug_log_path, "rb") as dl:
151151
seek_pos = node.debug_log_size(mode="rb") - 100 * 1024 # read the last 100 KiB only
152152
dl.seek(seek_pos if seek_pos > 0 else 0)
153-
debug_log_part = dl.read()
153+
debug_log_part = dl.read().decode("utf-8", errors="replace")
154154
return expected_msg in debug_log_part
155155

156156
for node in self.nodes[0:5]:

0 commit comments

Comments
 (0)