https://github.com/python/cpython/commit/3e81d56a1bfd2cc0afc01f1d9c126d286c4943ec commit: 3e81d56a1bfd2cc0afc01f1d9c126d286c4943ec branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: vstinner <[email protected]> date: 2025-06-23T10:51:51Z summary:
[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 6ab842fce50a6125797bcddfc4a4b2622aa6c6a9) Co-authored-by: Emma Smith <[email protected]> files: M Lib/test/test_perf_profiler.py diff --git a/Lib/test/test_perf_profiler.py b/Lib/test/test_perf_profiler.py index 03a4563dd924aa..d628acb165e6ae 100644 --- a/Lib/test/test_perf_profiler.py +++ b/Lib/test/test_perf_profiler.py @@ -497,9 +497,12 @@ def _is_perf_vesion_at_least(major, minor): # The output of perf --version looks like "perf version 6.7-3" but # it can also be perf version "perf version 5.15.143", or even include # a commit hash in the version string, like "6.12.9.g242e6068fd5c" + # + # PermissionError is raised if perf does not exist on the Windows Subsystem + # for Linux, see #134987 try: output = subprocess.check_output(["perf", "--version"], text=True) - except (subprocess.CalledProcessError, FileNotFoundError): + except (subprocess.CalledProcessError, FileNotFoundError, PermissionError): return False version = output.split()[2] version = version.split("-")[0] _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
