churchyard / rpms / python2

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