{"record":{"id":"bb6a94f25e53010a","repo":"pola-rs/polars","slug":"this-type-isn-t-exposed-to-python","errorCode":null,"errorMessage":"this type isn't exposed to python","messagePattern":"this type isn't exposed to python","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pyo3-polars/pyo3-polars/src/types.rs","lineNumber":484,"sourceCode":"                    })\n                    .collect::<PyResult<Vec<_>>>()?;\n                let fields = PyList::new(py, iter)?;\n                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)","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/pyo3-polars/pyo3-polars/src/types.rs#L466-L502","documentation":"When converting a Rust polars DataType into a Python dtype object, DataType::BinaryOffset has no Python-visible counterpart, so the conversion panics with 'this type isn't exposed to python'. This is an internal invariant: BinaryOffset should never reach the Python boundary.","triggerScenarios":"Rust code producing a schema/dtype containing BinaryOffset (the chunked-offset binary representation used internally) and then converting it via into_pyobject / IntoPyObject for DataType.","commonSituations":"Plugin or FFI code leaking internal representations into Python-facing APIs; reading schemas from low-level paths that preserve BinaryOffset; polars version drift where internal dtypes reach conversion code.","solutions":["Normalize BinaryOffset to pl.Binary before crossing the Python boundary (cast or map the dtype).","Fix the Rust-side code so internal dtypes never reach IntoPyObject conversions.","Report to polars if a public API surfaces BinaryOffset in a schema."],"exampleFix":"// before\nlet py_dtype = dtype.into_pyobject(py)?; // panics for BinaryOffset\n// after\nlet dtype = match dtype { DataType::BinaryOffset => DataType::Binary, d => d };\nlet py_dtype = dtype.into_pyobject(py)?;","handlingStrategy":"type-guard","validationCode":"# Rust: check before converting\nif matches!(dtype, DataType::BinaryOffset) {\n    return Err(PyValueError::new_err(\"BinaryOffset is not Python-exposed; use Binary\"));\n}","typeGuard":"fn is_python_exposed(dtype: &DataType) -> bool {\n    !matches!(dtype, DataType::BinaryOffset)\n}","tryCatchPattern":"# Python side: catch the panic-derived error at the boundary\ntry:\n    py_dtype = rust_dtype.to_python()\nexcept BaseException as e:\n    raise TypeError(f\"dtype not convertible to Python: {e}\") from e","preventionTips":["Normalize internal dtypes (BinaryOffset) to public ones before FFI conversion.","Keep an exhaustive match with an explicit error instead of panic! in library code.","Test schema round-trips through the Python boundary in CI."],"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"}