{"record":{"id":"d54a0d7a5bc978ba","repo":"pola-rs/polars","slug":"activate-dtype","errorCode":null,"errorMessage":"activate dtype","messagePattern":"activate dtype","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pyo3-polars/pyo3-polars/src/types.rs","lineNumber":487,"sourceCode":"                let struct_class = pl.getattr(intern!(py, \"Struct\")).unwrap();\n                struct_class.call1((fields,))\n            },\n            DataType::Null => {\n                let class = pl.getattr(intern!(py, \"Null\")).unwrap();\n                class.call0()\n            },\n            DataType::Unknown(UnknownKind::Int(v)) => {\n                PyDataType(materialize_dyn_int(*v).dtype()).into_pyobject(py)\n            },\n            DataType::Unknown(_) => {\n                let class = pl.getattr(intern!(py, \"Unknown\")).unwrap();\n                class.call0()\n            },\n            DataType::BinaryOffset => {\n                panic!(\"this type isn't exposed to python\")\n            },\n            #[allow(unreachable_patterns)]\n            _ => panic!(\"activate dtype\"),\n        }\n    }\n}\n\nimpl<'py> IntoPyObject<'py> for PySchema {\n    type Target = PyDict;\n    type Output = Bound<'py, Self::Target>;\n    type Error = PyErr;\n\n    fn into_pyobject(self, py: Python<'py>) -> Result<Self::Output, Self::Error> {\n        let dict = PyDict::new(py);\n        for (k, v) in self.0.iter() {\n            dict.set_item(k.as_str(), PyDataType(v.clone()).into_pyobject(py)?)?;\n        }\n        Ok(dict)\n    }\n}\n","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/pyo3-polars/pyo3-polars/src/types.rs#L469-L505","documentation":"The catch-all arm of DataType's IntoPyObject conversion panics with 'activate dtype' when it encounters a DataType variant with no Python mapping. It signals an unhandled/exhaustiveness gap in the Rust-to-Python dtype conversion rather than a user error.","triggerScenarios":"Converting a schema or expression output dtype whose variant (e.g. a new or Unknown-shaped dtype added in polars core) is not covered by the explicit match arms in pyo3-polars/types.rs.","commonSituations":"Using a newer polars core with an older pyo3-polars so new DataType variants appear; plugin code returning dtypes that were never mapped for Python conversion.","solutions":["Update pyo3-polars/src/types.rs to map the missing DataType variant to its Python class.","Align polars-core and pyo3-polars versions so all variants are covered.","Work around by mapping the dtype to a supported equivalent before conversion."],"exampleFix":"// before\nDataType::SomeNewVariant => panic!(\"activate dtype\"),\n// after\nDataType::SomeNewVariant => {\n    let class = pl.getattr(intern!(py, \"SomeNewVariant\"))?.cast()?;\n    class.call0()\n},","handlingStrategy":"try-catch","validationCode":"# Rust: guard before conversion\nif !is_known_dtype_variant(&dtype) {\n    return Err(PyNotImplementedError::new_err(format!(\"no Python mapping for {dtype:?}\")));\n}","typeGuard":"fn has_python_mapping(dtype: &DataType) -> bool {\n    !matches!(dtype, DataType::Unknown(_) | DataType::BinaryOffset)\n}","tryCatchPattern":"try:\n    schema = rust_schema.to_python()\nexcept BaseException as e:\n    log.error(\"dtype conversion failed; aligning polars versions may fix it: %s\", e)\n    raise","preventionTips":["Keep pyo3-polars and polars-core versions in lockstep.","Add match arms for every DataType variant and avoid unreachable catch-alls hiding gaps.","Add CI round-trip tests converting all DataType variants to Python."],"tags":["rust","pyo3","polars","panic","dtype"],"backgroundTag":"internal-invariant-violation","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}