{"record":{"id":"65757b7cb557cd61","repo":"PyO3/pyo3","slug":"python-stdout-len-didn-t-return-expected-number-of","errorCode":null,"errorMessage":"Python stdout len didn't return expected number of lines: {}","messagePattern":"Python stdout len didn't return expected number of lines: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pyo3-build-config/src/impl_.rs","lineNumber":1919,"sourceCode":"        if cfg!(windows) {\n            let script = String::from(\"import sys;print(sys.version_info < (3, 13))\");\n            let stdout = run_python_script(interpreter.as_ref(), &script)?;\n            if stdout.trim_end() == \"True\" {\n                return Ok(Self::new());\n            }\n        }\n\n        let mut script = String::from(\"import sysconfig\\n\");\n        script.push_str(\"config = sysconfig.get_config_vars()\\n\");\n\n        for k in &BuildFlags::ALL {\n            use std::fmt::Write;\n            writeln!(&mut script, \"print(config.get('{k}', '0'))\").unwrap();\n        }\n\n        let stdout = run_python_script(interpreter.as_ref(), &script)?;\n        let split_stdout: Vec<&str> = stdout.trim_end().lines().collect();\n        ensure!(\n            split_stdout.len() == BuildFlags::ALL.len(),\n            \"Python stdout len didn't return expected number of lines: {}\",\n            split_stdout.len()\n        );\n        let flags = BuildFlags::ALL\n            .iter()\n            .zip(split_stdout)\n            .filter(|(_, flag_value)| *flag_value == \"1\")\n            .map(|(flag, _)| flag.clone())\n            .collect();\n\n        Ok(Self(flags).fixup())\n    }\n\n    fn fixup(mut self) -> Self {\n        if self.0.contains(&BuildFlag::Py_DEBUG) {\n            self.0.insert(BuildFlag::Py_REF_DEBUG);\n        }","sourceCodeStart":1901,"sourceCodeEnd":1937,"githubUrl":"https://github.com/PyO3/pyo3/blob/ac9b6899d348be4d54614d060dea53a645a12e36/pyo3-build-config/src/impl_.rs#L1901-L1937","documentation":"Sanity check after running a small sysconfig query script with the target interpreter: the number of lines captured from the interpreter's stdout does not match the number of print statements the script emitted. The faulty input is the interpreter's output — truncated, buffered, or polluted (e.g. site banner noise) — so the build flags cannot be parsed reliably.","triggerScenarios":"Thrown at pyo3-build-config/src/impl_.rs:1919 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the failing interpreter manually with -c \"import sysconfig; ...\" and inspect its stdout for extra output or truncation","Disable site banners/user site packages (e.g. python -S) or print statements in sitecustomize that pollute stdout","Use a clean, unmodified interpreter installation for the build"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}