From: Sergey Miryanov Date: Sat, 2 May 2026 09:23:16 +0000 (+0500) Subject: GH-148932: Improve error message if profiling.sampling run from venv on Windows platf... X-Git-Tag: v3.15.0b1~122 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fea2a57282d243edd95c2166aa685c2568c47eaf;p=thirdparty%2FPython%2Fcpython.git GH-148932: Improve error message if profiling.sampling run from venv on Windows platform (#149247) --- diff --git a/Lib/profiling/sampling/sample.py b/Lib/profiling/sampling/sample.py index 6a76bbeeb24e..9195f5ee6dd3 100644 --- a/Lib/profiling/sampling/sample.py +++ b/Lib/profiling/sampling/sample.py @@ -58,6 +58,10 @@ class SampleProfiler: try: self.unwinder = self._new_unwinder(native, gc, opcodes, skip_non_matching_threads) except RuntimeError as err: + if os.name == "nt" and sys.executable.endswith("python.exe"): + raise SystemExit( + "Running profiling.sampling from virtualenv on Windows platform is not supported" + ) from err raise SystemExit(err) from err # Track sample intervals and total sample count self.sample_intervals = deque(maxlen=100)