Skip to content

[3.7] bpo-40436: Fix code parsing gdb version (GH-19792) #19796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/test/pythoninfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,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

Expand Down
10 changes: 8 additions & 2 deletions Lib/test/test_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@

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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test_gdb and test.pythoninfo now check gdb command exit code.