Skip to content

Commit f7ab4eb

Browse files
[3.13] gh-132038: Make perf version check in test_perf_profiler more robust (GH-132039) (#132058)
gh-132038: Make perf version check in test_perf_profiler more robust (GH-132039) Should work also if the version string includes a commit hash, like `perf version 6.12.9.g242e6068fd5c` (cherry picked from commit b6c92ec) Co-authored-by: Itamar Oren <[email protected]>
1 parent 832a691 commit f7ab4eb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/test/test_perf_profiler.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -482,15 +482,16 @@ def compile_trampolines_for_all_functions():
482482

483483
def _is_perf_vesion_at_least(major, minor):
484484
# The output of perf --version looks like "perf version 6.7-3" but
485-
# it can also be perf version "perf version 5.15.143"
485+
# it can also be perf version "perf version 5.15.143", or even include
486+
# a commit hash in the version string, like "6.12.9.g242e6068fd5c"
486487
try:
487488
output = subprocess.check_output(["perf", "--version"], text=True)
488489
except (subprocess.CalledProcessError, FileNotFoundError):
489490
return False
490491
version = output.split()[2]
491492
version = version.split("-")[0]
492493
version = version.split(".")
493-
version = tuple(map(int, version))
494+
version = tuple(map(int, version[:2]))
494495
return version >= (major, minor)
495496

496497

0 commit comments

Comments
 (0)