Skip to content

Commit c3dea8b

Browse files
committed
refactor: update pyo3 to 0.23
1 parent 3409d14 commit c3dea8b

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "djc_core_html_parser"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.22.0", features = ["extension-module"] }
12+
pyo3 = { version = "0.23.0", features = ["extension-module"] }
1313
quick-xml = "0.37.2"
1414

1515
# https://ohadravid.github.io/posts/2023-03-rusty-python

src/html_parser.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,17 @@ pub fn set_html_attributes(
6060
match transform(&config, html) {
6161
Ok((html, captured)) => {
6262
// Convert captured attributes to a Python dictionary
63-
let captured_dict = PyDict::new_bound(py);
63+
let captured_dict = PyDict::new(py);
6464
for (id, attrs) in captured {
6565
captured_dict.set_item(id, attrs)?;
6666
}
6767

68-
let result = PyTuple::new_bound(py, &[html.into_py(py), captured_dict.into_py(py)]);
69-
Ok(result.into())
68+
// Convert items to Bound<PyAny> for the tuple
69+
use pyo3::types::PyString;
70+
let html_obj = PyString::new(py, &html).as_any().clone();
71+
let dict_obj = captured_dict.as_any().clone();
72+
let result = PyTuple::new(py, vec![html_obj, dict_obj])?;
73+
Ok(result.into_any().unbind())
7074
}
7175
Err(e) => Err(PyValueError::new_err(e.to_string())),
7276
}

0 commit comments

Comments
 (0)