From 8bd3415aefbb4617259bea01ee050f5d5ccbcb0a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sat, 16 Aug 2014 14:31:02 +0200 Subject: [PATCH] Closes #22188: test_gdb now runs gdb with -nx: "Do not execute commands from any .gdbinit initialization files". --- Lib/test/test_gdb.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py index 6bbe05c3c9..f2c3c9070c 100644 --- a/Lib/test/test_gdb.py +++ b/Lib/test/test_gdb.py @@ -13,7 +13,7 @@ import sysconfig from test.test_support import run_unittest, findfile try: - gdb_version, _ = subprocess.Popen(["gdb", "--version"], + gdb_version, _ = subprocess.Popen(["gdb", "-nx", "--version"], stdout=subprocess.PIPE).communicate() except OSError: # This is what "no gdb" looks like. There may, however, be other @@ -31,7 +31,7 @@ checkout_hook_path = os.path.join(os.path.dirname(sys.executable), 'python-gdb.py') def run_gdb(*args, **env_vars): - """Runs gdb in --batch mode with the additional arguments given by *args. + """Runs gdb in batch mode with the additional arguments given by *args. Returns its (stdout, stderr) """ @@ -40,7 +40,9 @@ def run_gdb(*args, **env_vars): env.update(env_vars) else: env = None - base_cmd = ('gdb', '--batch') + # -nx: Do not execute commands from any .gdbinit initialization files + # (issue #22188) + base_cmd = ('gdb', '--batch', '-nx') if (gdb_major_version, gdb_minor_version) >= (7, 4): base_cmd += ('-iex', 'add-auto-load-safe-path ' + checkout_hook_path) out, err = subprocess.Popen(base_cmd + args, @@ -122,7 +124,7 @@ class DebuggerTests(unittest.TestCase): # print commands # Use "commands" to generate the arguments with which to invoke "gdb": - args = ["gdb", "--batch"] + args = ["gdb", "--batch", "-nx"] args += ['--eval-command=%s' % cmd for cmd in commands] args += ["--args", sys.executable] -- 2.50.1