Skip to content

Commit 9b96a0e

Browse files
util/helper: fix appending \n to unterminated final streamed chunks in ProcessWrapper
Addressing bytes by index returns an integer: In [1]: b"foo\n"[-1] Out[1]: 10 This means the condition is accidentally always true. Fix that by using endswith(). Found by Claude Opus 4.8. Signed-off-by: Bastian Krause <bst@pengutronix.de>
1 parent 63749cf commit 9b96a0e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

labgrid/util/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def check_output(self, command, *, print_on_silent_log=False, input=None, stdin=
135135
if buf:
136136
# process incomplete line
137137
res.append(buf)
138-
if buf[-1] != b'\n':
138+
if not buf.endswith(b'\n'):
139139
buf += b'\n'
140140
for callback in self.callbacks:
141141
callback(buf, process)

0 commit comments

Comments
 (0)