Blame SOURCES/00156-gdb-autoload-safepath.patch

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