test: do not let one bad byte take down the whole test run

bitcoin/bitcoin: PR #36850

1 suggestion

Optional improvements

Link

[suggestion] · Replacement decoding discards diagnostic byte values

Using backslashreplace would preserve undecodable byte values in test failure reports without restoring the decode crash; no current default path feeding raw node output into the runner's capture was confirmed.

Location: test/functional/test_runner.py:773 (head).

Details and suggested fix

get_next() closes the capture files immediately after decoding, and failed-test reporting prints only the resulting strings. For the new test's b"Assertion failed\x80\x81 at 0x7f\n", replacement characters therefore hide the original byte values from the runner's report. Use decode('utf-8', errors='backslashreplace') to display them as \x80\x81 instead. This still avoids UnicodeDecodeError, preserves valid UTF-8, and keeps nonempty stderr nonempty, so classification is unchanged. The malformed-byte test could assert the escaped values as well as the surrounding text. This concerns the runner's captured copy: TestNode.start() normally writes node stderr to a separate file retained with delete=False.


Coverage details