From d032522fe5a1fd277c72c999b67b1cccc87a12d5 Mon Sep 17 00:00:00 2001 From: Misaki Kasumi Date: Sun, 7 Jul 2024 17:18:02 +0800 Subject: [PATCH] feat(rust): auto select compat_level in PySeries::extract_bound --- pyo3-polars/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyo3-polars/src/lib.rs b/pyo3-polars/src/lib.rs index c627b48..6c311de 100644 --- a/pyo3-polars/src/lib.rs +++ b/pyo3-polars/src/lib.rs @@ -127,7 +127,12 @@ impl<'a> FromPyObject<'a> for PySeries { let name = py_name.to_cow()?; let kwargs = PyDict::new_bound(ob.py()); - kwargs.set_item("future", true)?; + if let Ok(compat_level) = ob.call_method0("_newest_compat_level") { + let compat_level = compat_level.extract().unwrap(); + let compat_level = + CompatLevel::with_level(compat_level).unwrap_or(CompatLevel::newest()); + kwargs.set_item("compat_level", compat_level.get_level())?; + } let arr = ob.call_method("to_arrow", (), Some(&kwargs))?; let arr = ffi::to_rust::array_to_rust(&arr)?; Ok(PySeries(