{"record":{"id":"80c99001773bfca6","repo":"PyO3/pyo3","slug":"unknown-py-gil-disabled-value","errorCode":null,"errorMessage":"Unknown Py_GIL_DISABLED value","messagePattern":"Unknown Py_GIL_DISABLED value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pyo3-build-config/src/impl_.rs","lineNumber":527,"sourceCode":"        let shared = map[\"shared\"].as_str() == \"True\";\n        let python_framework_prefix = map.get(\"python_framework_prefix\").cloned();\n\n        let version = PythonVersion {\n            major: map[\"version_major\"]\n                .parse()\n                .context(\"failed to parse major version\")?,\n            minor: map[\"version_minor\"]\n                .parse()\n                .context(\"failed to parse minor version\")?,\n        };\n\n        let implementation = map[\"implementation\"].parse()?;\n\n        let gil_disabled = match map[\"gil_disabled\"].as_str() {\n            \"1\" => true,\n            \"0\" => false,\n            \"None\" => false,\n            _ => panic!(\"Unknown Py_GIL_DISABLED value\"),\n        };\n\n        let stable_abi = applicable_stable_abi(\n            implementation,\n            version,\n            gil_disabled,\n            abi3_version,\n            abi3t_version,\n        );\n\n        let target_abi =\n            PythonAbi::from_stable_abi(implementation, version, stable_abi, gil_disabled)?;\n\n        let cygwin = map[\"cygwin\"].as_str() == \"True\";\n\n        let lib_name = if cfg!(windows) {\n            default_lib_name_windows(\n                target_abi,","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/PyO3/pyo3/blob/ac9b6899d348be4d54614d060dea53a645a12e36/pyo3-build-config/src/impl_.rs#L509-L545","documentation":"pyo3-build-config parses the interpreter config emitted by an already-running Python interpreter (via from_interpreter). Py_GIL_DISABLED must be \"1\", \"0\", or \"None\"; any other value means the reported config is unrecognizable, so parsing panics rather than guessing whether free-threading is enabled.","triggerScenarios":"Calling from_interpreter with a config map whose gil_disabled value is anything other than \"1\", \"0\", or \"None\" — typically when the python-config JSON was produced by an unusual, patched, or newer interpreter emitting a novel value.","commonSituations":"Embedding a custom or vendor-patched CPython build whose sysconfig reports a different Py_GIL_DISABLED encoding; using a bleeding-edge free-threading build with format changes; hand-edited interpreter config files.","solutions":["Check what `import sysconfig; sysconfig.get_config_var('Py_GIL_DISABLED')` prints and upgrade/downgrade pyo3 to a version that understands it","Use a standard CPython release (or a pyo3 version matching the interpreter's development line)","Inspect the config passed to from_interpreter and fix the gil_disabled field to \"0\"/\"1\"/\"None\""],"exampleFix":"// before (config map)\n{\"gil_disabled\": \"yes\"}\n// after\n{\"gil_disabled\": \"0\"}","handlingStrategy":"validation","validationCode":"fn validate_gil_disabled(v: &str) -> Result<bool, String> {\n    match v {\n        \"1\" => Ok(true),\n        \"0\" | \"None\" => Ok(false),\n        other => Err(format!(\"unsupported Py_GIL_DISABLED value: {other}\")),\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check sysconfig.get_config_var('Py_GIL_DISABLED') on the target interpreter before building","Pin pyo3 versions that support your interpreter's config format","Avoid hand-editing interpreter config maps"],"tags":["build-config","python-interpreter","free-threading","panic"],"backgroundTag":"unknown-env-value","analyzedSha":"ac9b6899d348be4d54614d060dea53a645a12e36","analyzedAt":"2026-09-05T09:20:35.319Z","contentChangedAt":"2026-09-05T09:20:35.319Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}