https://github.com/python/cpython/commit/fea2a57282d243edd95c2166aa685c2568c47eaf
commit: fea2a57282d243edd95c2166aa685c2568c47eaf
branch: main
author: Sergey Miryanov <[email protected]>
committer: pablogsal <[email protected]>
date: 2026-05-02T09:23:16Z
summary:

GH-148932: Improve error message if profiling.sampling run from venv on Windows 
platform (#149247)

files:
M Lib/profiling/sampling/sample.py

diff --git a/Lib/profiling/sampling/sample.py b/Lib/profiling/sampling/sample.py
index 6a76bbeeb24ee3..9195f5ee6dd390 100644
--- a/Lib/profiling/sampling/sample.py
+++ b/Lib/profiling/sampling/sample.py
@@ -58,6 +58,10 @@ def __init__(self, pid, sample_interval_usec, all_threads, 
*, mode=PROFILING_MOD
         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)

_______________________________________________
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]

Reply via email to