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

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