gh-98894: Check readelf failures in test_dtrace#152345
Conversation
Report readelf command failures directly instead of later failing with missing-probe assertions.
|
cc @vstinner |
vstinner
left a comment
There was a problem hiding this comment.
get_readelf_version() and get_readelf_output() share most code to spawn the subprocess. Can you move the common code into a run_readelf(command) function?
Something like:
def run_readelf(cmd):
# Force the C locale to disable localization.
env = dict(os.environ, LC_ALL="C")
proc = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
env=env,
)
with proc:
stdout, stderr = proc.communicate()
if proc.returncode:
raise AssertionError(
f"Command {' '.join(cmd)!r} failed "
f"with exit code {proc.returncode}: "
f"stdout={version!r} stderr={stderr!r}"
)
return stdout
You can replace legacy universal_newlines=True with text=True :-)
|
Thanks @stratakis for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
Sorry, @stratakis and @vstinner, I could not cleanly backport this to |
|
Sorry, @stratakis and @vstinner, I could not cleanly backport this to |
|
GH-152891 is a backport of this pull request to the 3.15 branch. |
|
3.14 and 3.13 are not relevant here due to the dtrace support not being there in a proper way (it will to be backported fully from #142397 ) |
|
Merged, thanks for your fix.
Oh ok. No 3.13 and 3.14 backport in this case. |
Report readelf command failures directly instead of later failing with missing-probe assertions.