Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f3ac1e

Browse files
committed
test_gdb: fix regex to parse gdb version for SUSE Linux Entreprise
Mention also the detected GDB version on verbose mode and on error (if the major version is smaller than 7).
1 parent 5492d35 commit 2f3ac1e

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

Lib/test/test_gdb.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,19 @@
2828
# This is what "no gdb" looks like. There may, however, be other
2929
# errors that manifest this way too.
3030
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)
3237
gdb_major_version = int(gdb_version_number.group(1))
3338
gdb_minor_version = int(gdb_version_number.group(2))
3439
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')))
3744

3845
if not sysconfig.is_python_build():
3946
raise unittest.SkipTest("test_gdb only works on source builds at the moment.")
@@ -878,7 +885,7 @@ def test_locals_after_up(self):
878885

879886
def test_main():
880887
if support.verbose:
881-
print("GDB version:")
888+
print("GDB version %s.%s:" % (gdb_major_version, gdb_minor_version))
882889
for line in os.fsdecode(gdb_version).splitlines():
883890
print(" " * 4 + line)
884891
run_unittest(PrettyPrintTests,

0 commit comments

Comments
 (0)