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

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