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."""
1fa9c84
@@ -112,15 +125,28 @@ class DebuggerTests(unittest.TestCase):
1fa9c84
                     'set print entry-values no',
1fa9c84
 
9261681
                     'run']
1fa9c84
+
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
+
9261681
         if cmds_after_breakpoint:
9261681
             commands += cmds_after_breakpoint
1fa9c84
         else:
1fa9c84
             commands += ['backtrace']
1fa9c84
 
1fa9c84
+        # print init_commands
1fa9c84
         # print commands
1fa9c84
 
1fa9c84
         # Use "commands" to generate the arguments with which to invoke "gdb":
1fa9c84
         args = ["gdb", "--batch"]
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]