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