|
28 | 28 | # This is what "no gdb" looks like. There may, however, be other |
29 | 29 | # errors that manifest this way too. |
30 | 30 | raise unittest.SkipTest("Couldn't find gdb on the path") |
31 | | -gdb_version_number = re.search(b"^GNU gdb [^\d]*(\d+)\.(\d)", gdb_version) |
| 31 | +# Regex to parse: |
| 32 | +# 'GNU gdb (GDB; SUSE Linux Enterprise 12) 7.7\n' -> 7.7 |
| 33 | +# 'GNU gdb (GDB) Fedora 7.9.1-17.fc22\n' -> 7.9 |
| 34 | +gdb_version_number = re.search(b"^GNU gdb .*? (\d+)\.(\d)", gdb_version) |
| 35 | +if not gdb_version_number: |
| 36 | + raise Exception("unable to parse GDB version: %a" % gdb_version) |
32 | 37 | gdb_major_version = int(gdb_version_number.group(1)) |
33 | 38 | gdb_minor_version = int(gdb_version_number.group(2)) |
34 | 39 | if gdb_major_version < 7: |
35 | | - raise unittest.SkipTest("gdb versions before 7.0 didn't support python embedding" |
36 | | - " Saw:\n" + gdb_version.decode('ascii', 'replace')) |
| 40 | + raise unittest.SkipTest("gdb versions before 7.0 didn't support python " |
| 41 | + "embedding. Saw %s.%s:\n%s" |
| 42 | + % (gdb_major_version, gdb_minor_version, |
| 43 | + gdb_version.decode('ascii', 'replace'))) |
37 | 44 |
|
38 | 45 | if not sysconfig.is_python_build(): |
39 | 46 | raise unittest.SkipTest("test_gdb only works on source builds at the moment.") |
@@ -878,7 +885,7 @@ def test_locals_after_up(self): |
878 | 885 |
|
879 | 886 | def test_main(): |
880 | 887 | if support.verbose: |
881 | | - print("GDB version:") |
| 888 | + print("GDB version %s.%s:" % (gdb_major_version, gdb_minor_version)) |
882 | 889 | for line in os.fsdecode(gdb_version).splitlines(): |
883 | 890 | print(" " * 4 + line) |
884 | 891 | run_unittest(PrettyPrintTests, |
|
0 commit comments