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

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