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

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