Skip to content

Commit 6ab842f

Browse files
authored
gh-134986: Catch PermissionError when trying to call perf in tests (#134987)
Using Ubuntu 24.04 on the Windows Subsystem for Linux, perf will raise a `PermissionError` instead of `FileNotFoundError`. This commit modifies the tests to catch that.
1 parent 0d9d489 commit 6ab842f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Lib/test/test_perf_profiler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,12 @@ def _is_perf_version_at_least(major, minor):
506506
# The output of perf --version looks like "perf version 6.7-3" but
507507
# it can also be perf version "perf version 5.15.143", or even include
508508
# a commit hash in the version string, like "6.12.9.g242e6068fd5c"
509+
#
510+
# PermissionError is raised if perf does not exist on the Windows Subsystem
511+
# for Linux, see #134987
509512
try:
510513
output = subprocess.check_output(["perf", "--version"], text=True)
511-
except (subprocess.CalledProcessError, FileNotFoundError):
514+
except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
512515
return False
513516
version = output.split()[2]
514517
version = version.split("-")[0]

0 commit comments

Comments
 (0)