Repository navigation
Unhandled BytesWarning when test.support.strace_helper.strace_python fails #127747
Description
Activity
@andreas-schwab Could you provide some more details about the error? For example: which platform are you using, how did you start the tests (from the message above I gather you are running the cpython unit tests), how did you install or compile cpython, is python itself running as expected?
This is the actual test failure:
test test_subprocess crashed -- Traceback (most recent call last): File "/home/abuild/rpmbuild/BUILD/Python-3.14.0a2/Lib/test/libregrtest/single.py", line 181, in _runtest_env_changed_exc _load_run_test(result, runtests) ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^ File "/home/abuild/rpmbuild/BUILD/Python-3.14.0a2/Lib/test/libregrtest/single.py", line 128, in _load_run_test test_mod = importlib.import_module(module_name) File "/home/abuild/rpmbuild/BUILD/Python-3.14.0a2/Lib/importlib/__init__.py", line 88, in import_module return _bootstrap._gcd_import(name[level:], package, level) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1386, in _gcd_import File "<frozen importlib._bootstrap>", line 1359, in _find_and_load File "<frozen importlib._bootstrap>", line 1330, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 935, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 756, in exec_module File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "/home/abuild/rpmbuild/BUILD/Python-3.14.0a2/Lib/test/test_subprocess.py", line 1843, in <module> class POSIXProcessTestCase(BaseTestCase): ...<1628 lines>... self.assertNotRegex(non_vfork_result.event_bytes, br"(?i)vfork") File "/home/abuild/rpmbuild/BUILD/Python-3.14.0a2/Lib/test/test_subprocess.py", line 3420, in POSIXProcessTestCase @strace_helper.requires_strace() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "/home/abuild/rpmbuild/BUILD/Python-3.14.0a2/Lib/test/support/strace_helper.py", line 166, in requires_strace return unittest.skipUnless(_can_strace(), "Requires working strace") ~~~~~~~~~~~^^ File "/home/abuild/rpmbuild/BUILD/Python-3.14.0a2/Lib/test/support/strace_helper.py", line 153, in _can_strace res = strace_python("import sys; sys.exit(0)", [], check=False) File "/home/abuild/rpmbuild/BUILD/Python-3.14.0a2/Lib/test/support/strace_helper.py", line 105, in strace_python return _make_error("Expected strace events and exit code line", stripped[-50:]) File "/home/abuild/rpmbuild/BUILD/Python-3.14.0a2/Lib/test/support/strace_helper.py", line 85, in _make_error event_bytes=f"error({reason},details={details}) = -1".encode('utf-8'), ^^^^^^^^^ BytesWarning: str() on a bytes instance- changed the title
[-]AssertionError: unhandled warning {message : BytesWarning('str() on a bytes instance'), category : 'BytesWarning', filename : '/home/abuild/rpmbuild/BUILD/Python-3.14.0a2/Lib/test/support/strace_helper.py', lineno : 85, line : None}[/-][+]Uhandled warning in `test_subprocess`[/+]on Dec 8, 2024 - changed the title
[-]Uhandled warning in `test_subprocess`[/-][+]Unhandled `BytesWarning('str() on a bytes instance')` in `test_subprocess`[/+]on Dec 8, 2024 Please, tell us how Python was configured and installed and how the tests were executed.
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errorpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on Dec 8, 2024 https://build.opensuse.org/package/live_build_log/openSUSE:Factory:RISCV/python314/standard/riscv64
./configure --host=riscv64-suse-linux --build=riscv64-suse-linux --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-platlibdir=lib64 --docdir=/usr/share/doc/packages/python --enable-ipv6 --enable-shared --with-ensurepip=no --with-system-ffi --with-system-expat --with-lto --with-ssl-default-suites=openssl --enable-optimizations --with-system-libmpdec --enable-loadable-sqlite-extensions
make
make testOk, my best guess is that the
stracehelper is not found, so something is raised. However, when we raise that error, we usedetails, which is likely a bytes instance and not a string one. Why? becausedetailsis probably obtained from stderr ofsubprocess.run(...)used to check the presence ofstrace, and we likely forgot to decode the output.I'll check this tomorrow and provide a patch if needed.
- removedpendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
on Dec 8, 2024 The error seems to be in
AutoFileTests.test_syscalls_readaccording to your logs. Note that thetest_vfork_used_when_expectedis also affected and it's actually the decorator that fails.cc @cmaloney as the one who added this decorator.
Reacted by Cody MaloneyWalking through the warning log + code looks like the strace binary exists but gave unexpected output. That leads to a call to the
_make_errorhelper (https://github.com/python/cpython/blob/main/Lib/test/support/strace_helper.py#L103-L109) where details is abytesrather than anOSErrororstr. I'd been using f-strings to format the output, and there is an implicit conversion from bytes -> str there... Not sure if there's a common / preferred way to fix, will experiment a bit.No, there is no strace installed.
Reacted by Cody Maloney- added a commit that references this issue
on Dec 10, 2024 - changed the title
[-]Unhandled `BytesWarning('str() on a bytes instance')` in `test_subprocess`[/-][+]Unhandled `BytesWarning('str() on a bytes instance')` when `test.support.strace_helper.strace_python` fails[/+]on Dec 10, 2024 - changed the title
[-]Unhandled `BytesWarning('str() on a bytes instance')` when `test.support.strace_helper.strace_python` fails[/-][+]Unhandled `BytesWarning when `test.support.strace_helper.strace_python` fails[/+]on Dec 10, 2024 - changed the title
[-]Unhandled `BytesWarning when `test.support.strace_helper.strace_python` fails[/-][+]Unhandled `BytesWarning` when `test.support.strace_helper.strace_python` fails[/+]on Dec 10, 2024
Linked PRs