Skip to content

Commit 3e81d56

Browse files
[3.13] gh-134986: Catch PermissionError when trying to call perf in tests (GH-134987) (#135842)
gh-134986: Catch PermissionError when trying to call perf in tests (GH-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. (cherry picked from commit 6ab842f) Co-authored-by: Emma Smith <emma@emmatyping.dev>
1 parent b79e64b commit 3e81d56

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
@@ -497,9 +497,12 @@ def _is_perf_vesion_at_least(major, minor):
497497
# The output of perf --version looks like "perf version 6.7-3" but
498498
# it can also be perf version "perf version 5.15.143", or even include
499499
# a commit hash in the version string, like "6.12.9.g242e6068fd5c"
500+
#
501+
# PermissionError is raised if perf does not exist on the Windows Subsystem
502+
# for Linux, see #134987
500503
try:
501504
output = subprocess.check_output(["perf", "--version"], text=True)
502-
except (subprocess.CalledProcessError, FileNotFoundError):
505+
except (subprocess.CalledProcessError, FileNotFoundError, PermissionError):
503506
return False
504507
version = output.split()[2]
505508
version = version.split("-")[0]

0 commit comments

Comments
 (0)