-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
Conversation
test_gdb and test.pythoninfo now check gdb command exit code.
@@ -376,6 +376,9 @@ def collect_gdb(info_add): | |||
stderr=subprocess.PIPE, | |||
universal_newlines=True) | |||
version = proc.communicate()[0] | |||
if proc.returncode: |
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:
if proc.returncode: | |
if proc.returncode != 0: |
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) ;-)
version = proc.communicate()[0] | ||
version, stderr = proc.communicate() | ||
|
||
if proc.returncode: |
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:
if proc.returncode: | |
if proc.returncode != 0: |
if proc.returncode: | ||
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 comment
The 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 comment
The 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:
match = re.search(r"^GNU gdb.*?\b(\d+)\.(\d+)", version)
if match is None:
raise Exception("unable to parse GDB version: %r" % version)
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
test_gdb and test.pythoninfo now check gdb command exit code. (cherry picked from commit ec9bea4) Co-authored-by: Victor Stinner <[email protected]>
GH-19795 is a backport of this pull request to the 3.8 branch. |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
test_gdb and test.pythoninfo now check gdb command exit code. (cherry picked from commit ec9bea4) Co-authored-by: Victor Stinner <[email protected]>
GH-19796 is a backport of this pull request to the 3.7 branch. |
test_gdb and test.pythoninfo now check gdb command exit code. (cherry picked from commit ec9bea4) Co-authored-by: Victor Stinner <[email protected]>
test_gdb and test.pythoninfo now check gdb command exit code. (cherry picked from commit ec9bea4) Co-authored-by: Victor Stinner <[email protected]>
test_gdb and test.pythoninfo now checks gdb command exit code.
https://bugs.python.org/issue40436