pola-rs/polars · error
object not supported
Error message
object not supported
What it means
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.
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.
Example fix
# before
result = my_plugin.my_expr(s) # s.dtype == pl.Object -> panic
# after
if s.dtype == pl.Object:
s = s.cast(pl.String)
result = my_plugin.my_expr(s) Defensive patterns
Strategy: validation
Validate before calling
if s.dtype == pl.Object or any(f.dtype == pl.Object for f in getattr(df.schema, 'fields', [])):
raise TypeError("Object dtype not supported by pyo3-polars plugin") Type guard
def is_plugin_safe(s: pl.Series) -> bool:
return s.dtype != pl.Object Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- activate dtype
- date not implemented for
- into_datetime not implemented for
- into_decimal( , ) not implemented for
- invalid from_physical
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/c955c49c077dab63.
Report an issue: GitHub.
Appendix: source
Thrown at pyo3-polars/pyo3-polars/src/types.rs:646
let inner = ob.getattr(intern!(py, "inner")).unwrap();
let size = ob.getattr(intern!(py, "size")).unwrap();
let inner = inner.extract::<PyDataType>()?;
let size = size.extract::<usize>()?;
DataType::Array(Box::new(inner.0), size)
},
#[cfg(feature = "dtype-struct")]
"Struct" => {
let fields = ob.getattr(intern!(py, "fields"))?;
let fields = fields
.extract::<Vec<PyField>>()?
.into_iter()
.map(|f| f.0)
.collect::<Vec<Field>>();
DataType::Struct(fields)
},
"Null" => DataType::Null,
#[cfg(feature = "object")]
"Object" => panic!("object not supported"),
"Unknown" => DataType::Unknown(Default::default()),
dt => {
return Err(PyTypeError::new_err(format!(
"'{dt}' is not a Polars data type, or the plugin isn't compiled with the right features",
)));
},
};
Ok(PyDataType(dtype))
}
}
View on GitHub (pinned to fe841f959e)