Skip to content

Commit 1f32415

Browse files
committed
Bump pyo3 to 0.26
1 parent bf810b5 commit 1f32415

File tree

8 files changed

+65
-65
lines changed

8 files changed

+65
-65
lines changed

Cargo.lock

Lines changed: 27 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "configcrunch"
3-
version = "1.1.0"
3+
version = "1.3.1"
44
authors = ["Marco Köpcke <[email protected]>"]
55
edition = "2024"
66
repository = "https://github.com/theCapypara/configcrunch"
@@ -12,7 +12,7 @@ crate-type = ["cdylib"]
1212
name = "configcrunch"
1313

1414
[dependencies]
15-
pyo3 = { version = "0.25", features = ["extension-module"] }
15+
pyo3 = { version = "0.26", features = ["extension-module"] }
1616
serde = { version = "1", features = ["derive"] }
1717
serde_yaml = "0.9"
1818
minijinja = "2"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "configcrunch"
7-
version = "1.3.0"
7+
version = "1.3.1"
88
description = "Configuration parser based on YAML-Files with support for variables, overlaying and hierarchies"
99
readme = "README.rst"
1010
requires-python = ">=3.11"

src/conv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl PyYamlConfigDocument {
4141
pub(crate) fn clone_ref(&self, py: Python) -> PyYamlConfigDocument {
4242
self.0.clone_ref(py).into()
4343
}
44-
pub(crate) fn getattr(&self, py: Python, attr: &str) -> PyResult<PyObject> {
44+
pub(crate) fn getattr(&self, py: Python, attr: &str) -> PyResult<Py<PyAny>> {
4545
self.0.getattr(py, attr)
4646
}
4747
pub(crate) fn borrow<'py>(&'py self, py: Python<'py>) -> PyRef<'py, YamlConfigDocument> {
@@ -67,7 +67,7 @@ pub(crate) enum YcdValueType {
6767
// only as a crutch! consider using ClonePyRef instead.
6868
impl Clone for YcdValueType {
6969
fn clone(&self) -> Self {
70-
Python::with_gil(|py| self.clone_pyref(py))
70+
Python::attach(|py| self.clone_pyref(py))
7171
}
7272
}
7373

@@ -199,7 +199,7 @@ impl Serialize for PyYamlConfigDocument {
199199
where
200200
S: Serializer,
201201
{
202-
Python::with_gil(|py| serializer.collect_map(&self.0.borrow(py).doc))
202+
Python::attach(|py| serializer.collect_map(&self.0.borrow(py).doc))
203203
}
204204
}
205205

src/merger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ pub(crate) fn resolve_and_merge(
402402
pub(crate) fn load_subdocument(
403403
py: Python,
404404
doc: &mut YcdValueType,
405-
args: &[PyObject; 4],
405+
args: &[Py<PyAny>; 4],
406406
doc_clss: Py<PyType>,
407407
lookup_paths: &[String],
408408
) -> PyResult<YcdValueType> {

src/minijinja.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ use crate::pyutil::ClonePyRef;
77
use crate::{FORCE_STRING, YamlConfigDocument};
88
use minijinja::value::{Object, Value, ValueKind};
99
use minijinja::{Environment, Error, ErrorKind, State};
10+
use pyo3::IntoPyObjectExt;
11+
use pyo3::prelude::*;
1012
use pyo3::types::PyTuple;
11-
use pyo3::{Bound, IntoPyObject, IntoPyObjectExt, PyAny, PyObject, PyResult, Python};
1213
use serde::{Serialize, Serializer};
1314

1415
// https://github.com/rust-lang/rust/issues/70263
@@ -67,7 +68,7 @@ impl<'env> TemplateRenderer<'env> {
6768
Ok(Some(result))
6869
}
6970

70-
pub(crate) fn add_helpers(&mut self, py: Python, helpers: Vec<PyObject>) {
71+
pub(crate) fn add_helpers(&mut self, py: Python, helpers: Vec<Py<PyAny>>) {
7172
self.globals.extend(helpers.into_iter().map(|f| {
7273
(
7374
f.getattr(py, "__name__").unwrap().extract(py).unwrap(),
@@ -81,11 +82,11 @@ impl<'env> TemplateRenderer<'env> {
8182
Value::from_object(document)
8283
}
8384

84-
pub fn create_helper_fn(pyf: PyObject) -> Box<FuncFunc> {
85+
pub fn create_helper_fn(pyf: Py<PyAny>) -> Box<FuncFunc> {
8586
Box::new(typed_closure!(
8687
(Fn(&State, &[Value]) -> Result<Value, Error> + Sync + Send + 'static),
8788
move |_state: &State, args: &[Value]| -> Result<Value, Error> {
88-
Python::with_gil(|py| {
89+
Python::attach(|py| {
8990
let pyargs = PyTuple::new(py, args.iter().cloned().map(WValue))
9091
.expect("Failed to construct Python tuple");
9192

@@ -104,7 +105,7 @@ impl<'env> TemplateRenderer<'env> {
104105

105106
impl Display for PyYamlConfigDocument {
106107
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
107-
Python::with_gil(
108+
Python::attach(
108109
|py| match YamlConfigDocument::__str__(self.0.clone_ref(py), py) {
109110
Ok(v) => write!(f, "{}", v),
110111
Err(_) => write!(f, "YCD<?? Error during Display ??>",),
@@ -168,14 +169,14 @@ impl From<&YcdValueType> for Value {
168169
match in_v {
169170
YcdValueType::Dict(v) => {
170171
// TODO: Not ideal
171-
Python::with_gil(|py| Value::from_object(YHashMap(v.clone_pyref(py))))
172+
Python::attach(|py| Value::from_object(YHashMap(v.clone_pyref(py))))
172173
}
173174
YcdValueType::List(v) => v.iter().map(|v| v.into()).collect::<Vec<Value>>().into(),
174175
YcdValueType::YString(v) => Value::from(v.clone()),
175176
YcdValueType::Bool(v) => Value::from(*v),
176177
YcdValueType::Int(v) => Value::from(*v),
177178
YcdValueType::Float(v) => Value::from(*v),
178-
YcdValueType::Ycd(v) => Python::with_gil(|py| Value::from_object(v.clone_ref(py))),
179+
YcdValueType::Ycd(v) => Python::attach(|py| Value::from_object(v.clone_ref(py))),
179180
}
180181
}
181182
}
@@ -208,7 +209,7 @@ impl<'py> IntoPyObject<'py> for WValue {
208209
}
209210

210211
#[derive(Debug)]
211-
struct VariableHelper(PyObject);
212+
struct VariableHelper(Py<PyAny>);
212213

213214
impl Display for VariableHelper {
214215
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
@@ -218,14 +219,14 @@ impl Display for VariableHelper {
218219

219220
impl Object for VariableHelper {
220221
fn call(self: &Arc<Self>, state: &State, args: &[Value]) -> Result<Value, Error> {
221-
Python::with_gil(|py| TemplateRenderer::create_helper_fn(self.0.clone_ref(py))(state, args))
222+
Python::attach(|py| TemplateRenderer::create_helper_fn(self.0.clone_ref(py))(state, args))
222223
}
223224
}
224225

225226
impl Object for PyYamlConfigDocument {
226227
fn get_value(self: &Arc<Self>, key: &Value) -> Option<Value> {
227228
let name = key.as_str()?;
228-
Python::with_gil(|py| {
229+
Python::attach(|py| {
229230
let mut bow = self.0.borrow(py);
230231
bow.doc.get(name).map(|x| x.into()).or_else(|| {
231232
if bow.bound_helpers.is_empty() {
@@ -250,7 +251,7 @@ impl Object for PyYamlConfigDocument {
250251
name: &str,
251252
args: &[Value],
252253
) -> Result<Value, Error> {
253-
Python::with_gil(|py| {
254+
Python::attach(|py| {
254255
let mut bow = self.0.borrow(py);
255256
if bow.bound_helpers.is_empty() {
256257
drop(bow);
@@ -303,7 +304,7 @@ impl Object for YHashMap<String, YcdValueType> {
303304
.map(|(k, v)| Value::from_serialize(YHashMapItem(k.clone(), v)))
304305
.collect::<Vec<Value>>(),
305306
)),
306-
"values" => Python::with_gil(|py| {
307+
"values" => Python::attach(|py| {
307308
Ok(Value::from(
308309
self.0
309310
.values()

src/variables.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl DocumentTraverser {
101101
in_str,
102102
document.borrow(py).absolute_paths[0]
103103
));
104-
let err_obj: PyObject = (&err).into_py_any(py)?;
104+
let err_obj: Py<PyAny> = (&err).into_py_any(py)?;
105105
let err_pyany: Bound<PyAny> = err_obj.extract(py)?;
106106
err_pyany.setattr("__cause__", orig_err.into_py_any(py)?)?;
107107
Err(err)
@@ -165,7 +165,7 @@ pub(crate) fn process_variables_for(
165165
py: Python,
166166
ycd: PyYamlConfigDocument,
167167
target: &str,
168-
additional_helpers: Vec<PyObject>,
168+
additional_helpers: Vec<Py<PyAny>>,
169169
) -> PyResult<YcdValueType> {
170170
let mut renderer: TemplateRenderer = TemplateRenderer::new(ycd.clone_ref(py))?;
171171
renderer.add_helpers(py, additional_helpers);

0 commit comments

Comments
 (0)