-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-40436: Fix code parsing gdb version #19792
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,12 +17,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: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I consider this more readable:
Suggested change
|
||||||
raise Exception(f"Command {' '.join(cmd)!r} failed " | ||||||
f"with exit code {proc.returncode}: " | ||||||
f"stdout={version!r} stderr={stderr!r}") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test is normally skipped if gdb is not found: raise unittest.SkipTest("Couldn't find gdb on the path") Should we not do the same? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test is still skipped when gdb is not found. But the new code is when gdb is available but is broken. I would prefer to not fail silently when gdb is broken, but get an error even if it's a third-party component. It should help to debug Python CIs like buildbots. It's like the existing test which raises an exception if Python fails to parse the gdb version:
|
||||||
except OSError: | ||||||
# This is what "no gdb" looks like. There may, however, be other | ||||||
# errors that manifest this way too. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test_gdb and test.pythoninfo now check gdb command exit code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider this more readable:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both syntaxes are equivalent. I prefer `if proc.returncode:" (coding style preference) ;-)