]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-127747: Resolve BytesWarning in test.support.strace_helper (#127849)
authorCody Maloney <cmaloney@users.noreply.github.com>
Sat, 14 Dec 2024 07:36:47 +0000 (23:36 -0800)
committerGitHub <noreply@github.com>
Sat, 14 Dec 2024 07:36:47 +0000 (23:36 -0800)
commitc0264fc57c51e68015bef95a2208711356b57c1f
tree8887222ce6fa57fa5278fce98c3370ff431fae36
parent2de048ce79e621f5ae0574095b9600fe8595f607
gh-127747: Resolve BytesWarning in test.support.strace_helper (#127849)

The strace_helper code has a _make_error function to simplify making
StraceResult objects in error cases. That takes a details parameter
which is either a caught OSError or `bytes`. If it's bytes, _make_error
would implicitly coerce that to a str inside of a f-string, resulting in
 a BytesWarning.

It's useful to see if it's an OSError or bytes when debugging, resolve
by changing to format with repr().

This is an error message on an internal helper.

A non-zero exit code occurs if the strace binary isn't found, and no
events will be parsed in that case (there is no output). Handle that
case by checking exit code before checking for events.

Still asserting around events rather than returning false, so that
hopefully if there's some change to `strace` that breaks the parsing,
will see that as a test failure rather than silently loosing strace
tests because they are auto-disabled.
Lib/test/support/strace_helper.py