Skip to content

Commit d9e9049

Browse files
bpo-40436: Fix code parsing gdb version (GH-19792)
test_gdb and test.pythoninfo now check gdb command exit code. (cherry picked from commit ec9bea4) Co-authored-by: Victor Stinner <[email protected]>
1 parent cc011b5 commit d9e9049

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Lib/test/pythoninfo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ def collect_gdb(info_add):
371371
stderr=subprocess.PIPE,
372372
universal_newlines=True)
373373
version = proc.communicate()[0]
374+
if proc.returncode:
375+
# ignore gdb failure: test_gdb will log the error
376+
return
374377
except OSError:
375378
return
376379

Lib/test/test_gdb.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@
1717

1818
def get_gdb_version():
1919
try:
20-
proc = subprocess.Popen(["gdb", "-nx", "--version"],
20+
cmd = ["gdb", "-nx", "--version"]
21+
proc = subprocess.Popen(cmd,
2122
stdout=subprocess.PIPE,
2223
stderr=subprocess.PIPE,
2324
universal_newlines=True)
2425
with proc:
25-
version = proc.communicate()[0]
26+
version, stderr = proc.communicate()
27+
28+
if proc.returncode:
29+
raise Exception(f"Command {' '.join(cmd)!r} failed "
30+
f"with exit code {proc.returncode}: "
31+
f"stdout={version!r} stderr={stderr!r}")
2632
except OSError:
2733
# This is what "no gdb" looks like. There may, however, be other
2834
# errors that manifest this way too.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test_gdb and test.pythoninfo now check gdb command exit code.

0 commit comments

Comments
 (0)