{"record":{"id":"c955c49c077dab63","repo":"pola-rs/polars","slug":"object-not-supported","errorCode":null,"errorMessage":"object not supported","messagePattern":"object not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pyo3-polars/pyo3-polars/src/types.rs","lineNumber":646,"sourceCode":"                let inner = ob.getattr(intern!(py, \"inner\")).unwrap();\n                let size = ob.getattr(intern!(py, \"size\")).unwrap();\n                let inner = inner.extract::<PyDataType>()?;\n                let size = size.extract::<usize>()?;\n                DataType::Array(Box::new(inner.0), size)\n            },\n            #[cfg(feature = \"dtype-struct\")]\n            \"Struct\" => {\n                let fields = ob.getattr(intern!(py, \"fields\"))?;\n                let fields = fields\n                    .extract::<Vec<PyField>>()?\n                    .into_iter()\n                    .map(|f| f.0)\n                    .collect::<Vec<Field>>();\n                DataType::Struct(fields)\n            },\n            \"Null\" => DataType::Null,\n            #[cfg(feature = \"object\")]\n            \"Object\" => panic!(\"object not supported\"),\n            \"Unknown\" => DataType::Unknown(Default::default()),\n            dt => {\n                return Err(PyTypeError::new_err(format!(\n                    \"'{dt}' is not a Polars data type, or the plugin isn't compiled with the right features\",\n                )));\n            },\n        };\n        Ok(PyDataType(dtype))\n    }\n}\n","sourceCodeStart":628,"sourceCodeEnd":657,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/pyo3-polars/pyo3-polars/src/types.rs#L628-L657","documentation":"A second, fuller conversion path for Python polars DataType -> Rust DataType explicitly panics with \"object not supported\" for the \"Object\" variant (types.rs:646). Unlike the todo!() path, this one makes the policy explicit: pyo3-polars intentionally rejects Object dtypes when extracting dtype information from Python objects. It is a hard Rust panic, not a recoverable Python exception.","triggerScenarios":"Extracting a PyDataType whose Python-side name is 'Object' (pl.Object) on a code path guarded by the 'object' cargo feature — e.g. dtype extraction from a Series, Field, or DataType argument passed to a plugin.","commonSituations":"Plugin users passing Series containing arbitrary Python objects; plugins built with feature flags matching the main polars-python build ('object' enabled) that then encounter Object columns.","solutions":["Cast or drop Object columns to a supported dtype (e.g. String) before invoking the plugin.","Rebuild the plugin without the 'object' feature so 'Object' resolves to the graceful PyTypeError branch instead of a panic.","Validate dtypes on the Python side (pl.Series.dtype checks) and raise a clear Python error before crossing the plugin boundary."],"exampleFix":"# before\nresult = my_plugin.my_expr(s)          # s.dtype == pl.Object -> panic\n# after\nif s.dtype == pl.Object:\n    s = s.cast(pl.String)\nresult = my_plugin.my_expr(s)","handlingStrategy":"validation","validationCode":"if s.dtype == pl.Object or any(f.dtype == pl.Object for f in getattr(df.schema, 'fields', [])):\n    raise TypeError(\"Object dtype not supported by pyo3-polars plugin\")","typeGuard":"def is_plugin_safe(s: pl.Series) -> bool:\n    return s.dtype != pl.Object","tryCatchPattern":null,"preventionTips":["Cast Object columns to String or another supported dtype before crossing the plugin boundary.","Keep plugin feature flags aligned with what your data actually contains.","Document the dtype restriction in your plugin's public API."],"tags":["polars","dtype","panic","unsupported","rust"],"backgroundTag":"unsupported-dtype","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"}