Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 84a6061

Browse files
authored
bpo-45207: Make test_gdb.test_pycfunction() quiet (GH-28355)
test_gdb.test_pycfunction() now ignores gdb stderr, it no longer logs messages like: Function "meth_varargs" not defined.
1 parent cc057ff commit 84a6061

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

Lib/test/test_gdb.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ class DebuggerTests(unittest.TestCase):
145145
def get_stack_trace(self, source=None, script=None,
146146
breakpoint=BREAKPOINT_FN,
147147
cmds_after_breakpoint=None,
148-
import_site=False):
148+
import_site=False,
149+
ignore_stderr=False):
149150
'''
150151
Run 'python -c SOURCE' under gdb with a breakpoint.
151152
@@ -224,8 +225,9 @@ def get_stack_trace(self, source=None, script=None,
224225
# Use "args" to invoke gdb, capturing stdout, stderr:
225226
out, err = run_gdb(*args, PYTHONHASHSEED=PYTHONHASHSEED)
226227

227-
for line in err.splitlines():
228-
print(line, file=sys.stderr)
228+
if not ignore_stderr:
229+
for line in err.splitlines():
230+
print(line, file=sys.stderr)
229231

230232
# bpo-34007: Sometimes some versions of the shared libraries that
231233
# are part of the traceback are compiled in optimised mode and the
@@ -909,6 +911,9 @@ def bar():
909911
cmd,
910912
breakpoint=func_name,
911913
cmds_after_breakpoint=['bt', 'py-bt'],
914+
# bpo-45207: Ignore 'Function "meth_varargs" not
915+
# defined.' message in stderr.
916+
ignore_stderr=True,
912917
)
913918
self.assertIn(f'<built-in method {func_name}', gdb_output)
914919

@@ -917,6 +922,9 @@ def bar():
917922
cmd,
918923
breakpoint=func_name,
919924
cmds_after_breakpoint=['py-bt-full'],
925+
# bpo-45207: Ignore 'Function "meth_varargs" not
926+
# defined.' message in stderr.
927+
ignore_stderr=True,
920928
)
921929
self.assertIn(
922930
f'#{expected_frame} <built-in method {func_name}',

0 commit comments

Comments
 (0)