From 79cfeedf2333392c35eb6903073cf5823f9cb2e9 Mon Sep 17 00:00:00 2001 From: Eduardo Villalpando Mello Date: Fri, 22 May 2026 14:11:08 -0700 Subject: [PATCH 1/3] gh-148932: `profiling.sampling` Windows limitations Updates the docs for `profiling.sampling` to note the limitation when running in a virtual environment on Windows platform. See #149560 --- Doc/library/profiling.sampling.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/library/profiling.sampling.rst b/Doc/library/profiling.sampling.rst index aeb1a429b58515a..7085c30551e54f3 100644 --- a/Doc/library/profiling.sampling.rst +++ b/Doc/library/profiling.sampling.rst @@ -387,6 +387,8 @@ This requires one of: On Windows, the profiler requires administrative privileges or the ``SeDebugPrivilege`` privilege to read another process's memory. +*Note*: Running `profiling.sampling` from a virtual environmnent on Windows platform is not supported. It should be run from the global Python installation. + Version compatibility --------------------- From d88deb07a0f136c8a1e2bfa6c366dcf369387b7a Mon Sep 17 00:00:00 2001 From: Eduardo Villalpando Mello Date: Fri, 22 May 2026 14:21:13 -0700 Subject: [PATCH 2/3] Fix linting issues --- Doc/library/profiling.sampling.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/profiling.sampling.rst b/Doc/library/profiling.sampling.rst index 7085c30551e54f3..b71c733425e64be 100644 --- a/Doc/library/profiling.sampling.rst +++ b/Doc/library/profiling.sampling.rst @@ -387,7 +387,7 @@ This requires one of: On Windows, the profiler requires administrative privileges or the ``SeDebugPrivilege`` privilege to read another process's memory. -*Note*: Running `profiling.sampling` from a virtual environmnent on Windows platform is not supported. It should be run from the global Python installation. +*Note*: Running ``profiling.sampling`` from a virtual environment on the Windows platform is not supported. It should be run from the global Python installation. Version compatibility From 3007c69b99a474ecbf0a4ae7c8fa10cf94b02cf5 Mon Sep 17 00:00:00 2001 From: Eduardo Villalpando Mello Date: Fri, 22 May 2026 17:18:11 -0700 Subject: [PATCH 3/3] Address PR Comments --- Doc/library/profiling.sampling.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Doc/library/profiling.sampling.rst b/Doc/library/profiling.sampling.rst index b71c733425e64be..39b6ea4e31cde72 100644 --- a/Doc/library/profiling.sampling.rst +++ b/Doc/library/profiling.sampling.rst @@ -387,8 +387,11 @@ This requires one of: On Windows, the profiler requires administrative privileges or the ``SeDebugPrivilege`` privilege to read another process's memory. -*Note*: Running ``profiling.sampling`` from a virtual environment on the Windows platform is not supported. It should be run from the global Python installation. - +*Note*: On Windows, ``python -m profiling.sampling`` fails inside a virtual +environment because the venv's ``python.exe`` is just a launcher shim that +re-executes the base interpreter as a child process. The shim itself isn't +a Python process and has no ``PyRuntime`` section to attach to. Instead, +run it from the global Python installation. Version compatibility ---------------------