summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-29 17:11:48 +0200
committerGitHub <noreply@github.com>2020-04-29 17:11:48 +0200
commitec9bea4a3766bd815148a27f61eb24e7dd459ac7 (patch)
tree808f462e186e6c7ff286186bac813af8488325c7 /Lib
parent9a8c1315c3041fdb85d091bb8dc92f0d9dcb1529 (diff)
downloadcpython-git-ec9bea4a3766bd815148a27f61eb24e7dd459ac7.tar.gz
bpo-40436: Fix code parsing gdb version (GH-19792)
test_gdb and test.pythoninfo now check gdb command exit code.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/pythoninfo.py3
-rw-r--r--Lib/test/test_gdb.py10
2 files changed, 11 insertions, 2 deletions
diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py
index cc230dd229..cc0bbc5fe3 100644
--- a/Lib/test/pythoninfo.py
+++ b/Lib/test/pythoninfo.py
@@ -376,6 +376,9 @@ def collect_gdb(info_add):
stderr=subprocess.PIPE,
universal_newlines=True)
version = proc.communicate()[0]
+ if proc.returncode:
+ # ignore gdb failure: test_gdb will log the error
+ return
except OSError:
return
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index fb1480145a..210cd0d378 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -17,12 +17,18 @@ from test.support import findfile, python_is_optimized
def get_gdb_version():
try:
- proc = subprocess.Popen(["gdb", "-nx", "--version"],
+ cmd = ["gdb", "-nx", "--version"]
+ proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True)
with proc:
- version = proc.communicate()[0]
+ version, stderr = proc.communicate()
+
+ if proc.returncode:
+ raise Exception(f"Command {' '.join(cmd)!r} failed "
+ f"with exit code {proc.returncode}: "
+ f"stdout={version!r} stderr={stderr!r}")
except OSError:
# This is what "no gdb" looks like. There may, however, be other
# errors that manifest this way too.