Skip to content

Commit 23c3bcf

Browse files
committed
Correct _FREE_THREADED_BUILD detection for Py_GIL_DISABLED
`sysconfig.get_config_var("Py_GIL_DISABLED")` may be defined as 0 on non-free-threaded builds. The previous check used `is not None`, which incorrectly treated `Py_GIL_DISABLED=0` as a free-threaded build. Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
1 parent 6d05e55 commit 23c3bcf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Lib/profiling/sampling/sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def _pause_threads(unwinder, blocking):
4141
except ImportError:
4242
LiveStatsCollector = None
4343

44-
_FREE_THREADED_BUILD = sysconfig.get_config_var("Py_GIL_DISABLED") is not None
44+
_FREE_THREADED_BUILD = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
4545
# Minimum number of samples required before showing the TUI
4646
# If fewer samples are collected, we skip the TUI and just print a message
4747
MIN_SAMPLES_FOR_TUI = 200

0 commit comments

Comments
 (0)