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

556498
diff -up Python-2.7.3/Lib/test/test_gdb.py.gdb-autoload-safepath Python-2.7.3/Lib/test/test_gdb.py
556498
--- Python-2.7.3/Lib/test/test_gdb.py.gdb-autoload-safepath	2012-04-30 15:53:57.254045220 -0400
556498
+++ Python-2.7.3/Lib/test/test_gdb.py	2012-04-30 16:19:19.569941124 -0400
556498
@@ -54,6 +54,19 @@ def gdb_has_frame_select():
556498
 
556498
 HAS_PYUP_PYDOWN = gdb_has_frame_select()
556498
 
556498
+def gdb_has_autoload_safepath():
556498
+    # Recent GDBs will only auto-load scripts from certain safe
556498
+    # locations, so we will need to turn off this protection.
556498
+    # However, if the GDB doesn't have it, then the following
556498
+    # command will generate noise on stderr (rhbz#817072):
556498
+    cmd = "--eval-command=set auto-load safe-path /"
556498
+    p = subprocess.Popen(["gdb", "--batch", cmd],
556498
+                         stderr=subprocess.PIPE)
556498
+    _, stderr = p.communicate()
556498
+    return '"on" or "off" expected.' not in stderr
556498
+    
556498
+HAS_AUTOLOAD_SAFEPATH = gdb_has_autoload_safepath()
556498
+
556498
 class DebuggerTests(unittest.TestCase):
556498
 
556498
     """Test that the debugger can debug Python."""
556498
diff -up Python-2.7.10/Lib/test/test_gdb.py.ms Python-2.7.10/Lib/test/test_gdb.py
556498
--- Python-2.7.10/Lib/test/test_gdb.py.ms	2015-05-25 17:00:25.028462615 +0200
556498
+++ Python-2.7.10/Lib/test/test_gdb.py	2015-05-25 17:01:53.166359822 +0200
556498
@@ -153,6 +153,17 @@ class DebuggerTests(unittest.TestCase):
556498
 
556498
                     'run']
556498
 
556498
+        if HAS_AUTOLOAD_SAFEPATH:
556498
+            # Recent GDBs will only auto-load scripts from certain safe
556498
+            # locations.
556498
+            # Where necessary, turn off this protection to ensure that
556498
+            # our -gdb.py script can be loaded - but not on earlier gdb builds
556498
+            # as this would generate noise on stderr (rhbz#817072):
556498
+            init_commands = ['set auto-load safe-path /']
556498
+        else:
556498
+            init_commands = []
556498
+
556498
+
556498
         # GDB as of 7.4 onwards can distinguish between the
556498
         # value of a variable at entry vs current value:
556498
         #   http://sourceware.org/gdb/onlinedocs/gdb/Variables.html
556498
@@ -167,10 +178,11 @@ class DebuggerTests(unittest.TestCase):
556498
         else:
556498
             commands += ['backtrace']
556498
 
556498
-        # print commands
556498
+        # print init_commands
556498
 
556498
         # Use "commands" to generate the arguments with which to invoke "gdb":
556498
         args = ["gdb", "--batch", "-nx"]
556498
+        args += ['--init-eval-command=%s' % cmd for cmd in init_commands]
556498
         args += ['--eval-command=%s' % cmd for cmd in commands]
556498
         args += ["--args",
556498
                  sys.executable]