926168
diff -up Python-2.7.3/Lib/test/test_gdb.py.gdb-autoload-safepath Python-2.7.3/Lib/test/test_gdb.py
1fa9c8
--- Python-2.7.3/Lib/test/test_gdb.py.gdb-autoload-safepath	2012-04-30 15:53:57.254045220 -0400
1fa9c8
+++ Python-2.7.3/Lib/test/test_gdb.py	2012-04-30 16:19:19.569941124 -0400
1fa9c8
@@ -54,6 +54,19 @@ def gdb_has_frame_select():
1fa9c8
 
1fa9c8
 HAS_PYUP_PYDOWN = gdb_has_frame_select()
926168
 
1fa9c8
+def gdb_has_autoload_safepath():
1fa9c8
+    # Recent GDBs will only auto-load scripts from certain safe
1fa9c8
+    # locations, so we will need to turn off this protection.
1fa9c8
+    # However, if the GDB doesn't have it, then the following
1fa9c8
+    # command will generate noise on stderr (rhbz#817072):
1fa9c8
+    cmd = "--eval-command=set auto-load safe-path /"
1fa9c8
+    p = subprocess.Popen(["gdb", "--batch", cmd],
1fa9c8
+                         stderr=subprocess.PIPE)
1fa9c8
+    _, stderr = p.communicate()
1fa9c8
+    return '"on" or "off" expected.' not in stderr
1fa9c8
+    
1fa9c8
+HAS_AUTOLOAD_SAFEPATH = gdb_has_autoload_safepath()
926168
+
1fa9c8
 class DebuggerTests(unittest.TestCase):
1fa9c8
 
1fa9c8
     """Test that the debugger can debug Python."""
1fa9c8
@@ -112,15 +125,28 @@ class DebuggerTests(unittest.TestCase):
1fa9c8
                     'set print entry-values no',
1fa9c8
 
926168
                     'run']
1fa9c8
+
1fa9c8
+        if HAS_AUTOLOAD_SAFEPATH:
1fa9c8
+            # Recent GDBs will only auto-load scripts from certain safe
1fa9c8
+            # locations.
1fa9c8
+            # Where necessary, turn off this protection to ensure that
1fa9c8
+            # our -gdb.py script can be loaded - but not on earlier gdb builds
1fa9c8
+            # as this would generate noise on stderr (rhbz#817072):
1fa9c8
+            init_commands = ['set auto-load safe-path /']
1fa9c8
+        else:
1fa9c8
+            init_commands = []
1fa9c8
+
926168
         if cmds_after_breakpoint:
926168
             commands += cmds_after_breakpoint
1fa9c8
         else:
1fa9c8
             commands += ['backtrace']
1fa9c8
 
1fa9c8
+        # print init_commands
1fa9c8
         # print commands
1fa9c8
 
1fa9c8
         # Use "commands" to generate the arguments with which to invoke "gdb":
1fa9c8
         args = ["gdb", "--batch"]
1fa9c8
+        args += ['--init-eval-command=%s' % cmd for cmd in init_commands]
1fa9c8
         args += ['--eval-command=%s' % cmd for cmd in commands]
1fa9c8
         args += ["--args",
1fa9c8
                  sys.executable]