1fe57a
diff -up Python-2.7.3/Lib/test/test_gdb.py.gdb-autoload-safepath Python-2.7.3/Lib/test/test_gdb.py
1fe57a
--- Python-2.7.3/Lib/test/test_gdb.py.gdb-autoload-safepath	2012-04-30 15:53:57.254045220 -0400
1fe57a
+++ Python-2.7.3/Lib/test/test_gdb.py	2012-04-30 16:19:19.569941124 -0400
1fe57a
@@ -54,6 +54,19 @@ def gdb_has_frame_select():
1fe57a
 
1fe57a
 HAS_PYUP_PYDOWN = gdb_has_frame_select()
1fe57a
 
1fe57a
+def gdb_has_autoload_safepath():
1fe57a
+    # Recent GDBs will only auto-load scripts from certain safe
1fe57a
+    # locations, so we will need to turn off this protection.
1fe57a
+    # However, if the GDB doesn't have it, then the following
1fe57a
+    # command will generate noise on stderr (rhbz#817072):
1fe57a
+    cmd = "--eval-command=set auto-load safe-path /"
1fe57a
+    p = subprocess.Popen(["gdb", "--batch", cmd],
1fe57a
+                         stderr=subprocess.PIPE)
1fe57a
+    _, stderr = p.communicate()
1fe57a
+    return '"on" or "off" expected.' not in stderr
1fe57a
+    
1fe57a
+HAS_AUTOLOAD_SAFEPATH = gdb_has_autoload_safepath()
1fe57a
+
1fe57a
 class DebuggerTests(unittest.TestCase):
1fe57a
 
1fe57a
     """Test that the debugger can debug Python."""
1fe57a
diff -up Python-2.7.10/Lib/test/test_gdb.py.ms Python-2.7.10/Lib/test/test_gdb.py
1fe57a
--- Python-2.7.10/Lib/test/test_gdb.py.ms	2015-05-25 17:00:25.028462615 +0200
1fe57a
+++ Python-2.7.10/Lib/test/test_gdb.py	2015-05-25 17:01:53.166359822 +0200
1fe57a
@@ -153,6 +153,17 @@ class DebuggerTests(unittest.TestCase):
1fe57a
 
1fe57a
                     'run']
1fe57a
 
1fe57a
+        if HAS_AUTOLOAD_SAFEPATH:
1fe57a
+            # Recent GDBs will only auto-load scripts from certain safe
1fe57a
+            # locations.
1fe57a
+            # Where necessary, turn off this protection to ensure that
1fe57a
+            # our -gdb.py script can be loaded - but not on earlier gdb builds
1fe57a
+            # as this would generate noise on stderr (rhbz#817072):
1fe57a
+            init_commands = ['set auto-load safe-path /']
1fe57a
+        else:
1fe57a
+            init_commands = []
1fe57a
+
1fe57a
+
1fe57a
         # GDB as of 7.4 onwards can distinguish between the
1fe57a
         # value of a variable at entry vs current value:
1fe57a
         #   http://sourceware.org/gdb/onlinedocs/gdb/Variables.html
1fe57a
@@ -167,10 +178,11 @@ class DebuggerTests(unittest.TestCase):
1fe57a
         else:
1fe57a
             commands += ['backtrace']
1fe57a
 
1fe57a
-        # print commands
1fe57a
+        # print init_commands
1fe57a
 
1fe57a
         # Use "commands" to generate the arguments with which to invoke "gdb":
1fe57a
         args = ["gdb", "--batch", "-nx"]
1fe57a
+        args += ['--init-eval-command=%s' % cmd for cmd in init_commands]
1fe57a
         args += ['--eval-command=%s' % cmd for cmd in commands]
1fe57a
         args += ["--args",
1fe57a
                  sys.executable]