From 6d39f95a0ddf1c957217828198920f7b2f0cf807 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 20 Oct 2026 11:48:29 -0700 Subject: [PATCH] gh-159914: Ignore gdb stderr in test_gdb.test_pretty_print (GH-159916) test_strings() gets gdb.host_charset(), but fails if gdb writes anything to stderr. For example, it fails if gdb logs the warning: "/usr/bin/gdb: warning: Couldn't determine a path for the index cache directory." Even if stdout contains the expected encoding ("UTF-8"). Change test_gdb to only fail if stdout is empty, ignore stderr otherwise to ignore gdb warnings. (cherry picked from commit 88d922ad982c4e00f8cb936cffba154d8d5fb697) Co-authored-by: Victor Stinner --- Lib/test/test_gdb/test_pretty_print.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_gdb/test_pretty_print.py b/Lib/test/test_gdb/test_pretty_print.py index ea047a12b802e8..04e06a64aaa5bb 100644 --- a/Lib/test/test_gdb/test_pretty_print.py +++ b/Lib/test/test_gdb/test_pretty_print.py @@ -125,7 +125,7 @@ def test_strings(self): 'python import gdb; print(gdb.host_charset())') encoding = stdout.strip() - if stderr or not encoding: + if not encoding: raise RuntimeError( f'unable to determine the host charset of gdb\n' f'stdout={stdout!r}\n'