Skip gdb if Python compiled with gdb not >= 2.5.
authorRobert Bradshaw <robertwb@math.washington.edu>
Sun, 23 Jan 2011 10:54:41 +0000 (02:54 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sun, 23 Jan 2011 10:54:41 +0000 (02:54 -0800)
Cython/Debugger/Tests/TestLibCython.py

index 436085c159eb89e7a16f16dcc0a8508905a90127..68746902667af6a52275c5c0870d26b3177a429f 100644 (file)
@@ -166,15 +166,27 @@ class GdbDebuggerTestCase(DebuggerTestCase):
             p.wait()
             p.stdout.close()
 
+        if have_gdb:
+            python_version_script = tempfile.NamedTemporaryFile()
+            python_version_script.write('python import sys; print sys.version_info\n')
+            python_version_script.flush()
+            p = subprocess.Popen(['gdb', '-batch', '-x', python_version_script.name],
+                                 stdout=subprocess.PIPE)
+            python_version = p.stdout.read().decode('ascii')
+            p.wait()
+            python_version_number = [int(a.strip()) for a in python_version.strip('()').split(',')[:3]]
+
         if have_gdb:
             # Based on Lib/test/test_gdb.py
             regex = "^GNU gdb [^\d]*(\d+)\.(\d+)"
             gdb_version_number = re.search(regex, gdb_version).groups()
 
         # Be Python 3 compatible
-        if not have_gdb or list(map(int, gdb_version_number)) < [7, 2]:
+        if (not have_gdb
+            or list(map(int, gdb_version_number)) < [7, 2]
+            or python_version_number < [2, 5]):
             self.p = None
-            warnings.warn('Skipping gdb tests, need gdb >= 7.2')
+            warnings.warn('Skipping gdb tests, need gdb >= 7.2 with Python >= 2.5')
         else:
             self.p = subprocess.Popen(
                 args,