{"record":{"id":"8adf97c8a1dff3e4","repo":"pola-rs/polars","slug":"activate-object-feature","errorCode":null,"errorMessage":"activate 'object' feature","messagePattern":"activate 'object' feature","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-python/src/series/construction.rs","lineNumber":374,"sourceCode":"    #[staticmethod]\n    #[pyo3(signature = (name, values, strict, dtype))]\n    fn new_array(\n        name: &str,\n        values: &Bound<PyAny>,\n        strict: bool,\n        dtype: Wrap<DataType>,\n    ) -> PyResult<Self> {\n        Self::new_from_any_values_and_dtype(name, values, dtype, strict)\n    }\n\n    #[staticmethod]\n    pub fn new_object(py: Python<'_>, name: &str, values: Vec<ObjectValue>, _strict: bool) -> Self {\n        #[cfg(feature = \"object\")]\n        {\n            PySeries::from(series_from_objects(py, name.into(), values))\n        }\n        #[cfg(not(feature = \"object\"))]\n        panic!(\"activate 'object' feature\")\n    }\n\n    #[staticmethod]\n    fn new_null(name: &str, values: &Bound<PyAny>, _strict: bool) -> PyResult<Self> {\n        let len = values.len()?;\n        Ok(Series::new_null(name.into(), len).into())\n    }\n\n    #[staticmethod]\n    fn from_arrow(name: &str, array: &Bound<PyAny>) -> PyResult<Self> {\n        let arr = array_to_rust(array)?;\n\n        // Compute first. The physical conversion retains offsets so the flag remains valid.\n        let fast_explode = arr\n            .as_any()\n            .downcast_ref::<LargeListArray>()\n            .is_some_and(|a| a.offsets().as_slice().windows(2).all(|w| w[0] != w[1]));\n","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-python/src/series/construction.rs#L356-L392","documentation":"new_object constructs a polars Series from arbitrary Python objects, but that capability only exists when the polars binary was compiled with the 'object' feature. Without it, the function panics with a directive to activate the feature. Official PyPI wheels include this feature; custom/minimal builds may not.","triggerScenarios":"Creating a Series with dtype=pl.Object (e.g. pl.Series('a', [some_python_object], dtype=pl.Object)) on a polars build compiled without the object feature; also hit by certain .map_elements / apply paths that fall back to object construction.","commonSituations":"Building polars from source with a reduced feature set; using slim/alternative builds or embedded environments (e.g. some WASM or minimal distributions) without the object feature.","solutions":["Install the official polars wheel from PyPI, which has the object feature enabled.","If building from source, enable the feature: cargo build/pip install with --features object (or the polars['all'] extras).","Avoid pl.Object: store data in supported dtypes, or keep Python objects outside the DataFrame.","Consider storing complex objects as serialized JSON/Binary columns instead."],"exampleFix":"# before (custom build without object feature)\ns = pl.Series('objs', [MyClass(), MyClass()], dtype=pl.Object)\n# after\npip install --upgrade --force-reinstall polars\ns = pl.Series('objs', [obj.to_dict() for obj in objs], dtype=pl.Struct)  # or reinstall official wheel","handlingStrategy":"validation","validationCode":"import polars\nassert 'object' in str(polars.build_info()) or hasattr(polars, 'Object'), \\\n    'polars build lacks object feature'","typeGuard":"def object_dtype_supported():\n    import polars\n    return 'object' in str(getattr(polars, 'build_info', lambda: '')()),","tryCatchPattern":"try:\n    s = pl.Series('a', values, dtype=pl.Object)\nexcept BaseException as e:\n    if 'object' in str(e) and 'feature' in str(e):\n        s = pl.Series('a', [json.dumps(v, default=str) for v in values])  # serialize instead\n    else:\n        raise","preventionTips":["Use official polars wheels where the object feature is enabled.","Prefer Struct/JSON columns over pl.Object.","Avoid map_elements/apply paths that materialize Python objects on slim builds."],"tags":["python","feature-flag","object-dtype","compile-time"],"backgroundTag":"feature-not-enabled","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"}