Skip to content

Commit beba1a8

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 adb1f85 commit beba1a8

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Lib/test/pythoninfo.py

+3
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ def collect_gdb(info_add):
340340
stderr=subprocess.PIPE,
341341
universal_newlines=True)
342342
version = proc.communicate()[0]
343+
if proc.returncode:
344+
# ignore gdb failure: test_gdb will log the error
345+
return
343346
except OSError:
344347
return
345348

Lib/test/test_gdb.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@
1818

1919
def get_gdb_version():
2020
try:
21-
proc = subprocess.Popen(["gdb", "-nx", "--version"],
21+
cmd = ["gdb", "-nx", "--version"]
22+
proc = subprocess.Popen(cmd,
2223
stdout=subprocess.PIPE,
2324
stderr=subprocess.PIPE,
2425
universal_newlines=True)
2526
with proc:
26-
version = proc.communicate()[0]
27+
version, stderr = proc.communicate()
28+
29+
if proc.returncode:
30+
raise Exception(f"Command {' '.join(cmd)!r} failed "
31+
f"with exit code {proc.returncode}: "
32+
f"stdout={version!r} stderr={stderr!r}")
2733
except OSError:
2834
# This is what "no gdb" looks like. There may, however, be other
2935
# errors that manifest this way too.
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)