10000 [3.14] gh-134986: Catch PermissionError when trying to call perf in t… · python/cpython@85fbf80 · GitHub
[go: up one dir, main page]

Skip to content

Commit 85fbf80

Browse files
[3.14] gh-134986: Catch PermissionError when trying to call perf in tests (GH-134987) (#135841)
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 f0a330e commit 85fbf80

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)
0