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