diff --git a/Cargo.toml b/Cargo.toml index a35d145..d83354a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ axum = "0.7" criterion = "0.5" futures = "0.3" http-types = "2" -pyo3 = "0.22" +pyo3 = "0.27" quickcheck = "1" rand = "0.8.4" tide = "0.16" diff --git a/src/encoding/text.rs b/src/encoding/text.rs index dcd97b5..fd050f4 100644 --- a/src/encoding/text.rs +++ b/src/encoding/text.rs @@ -1251,21 +1251,21 @@ mod tests { } fn parse_with_python_client(input: String) { - pyo3::prepare_freethreaded_python(); + pyo3::Python::initialize(); println!("{input:?}"); - Python::with_gil(|py| { - let parser = PyModule::from_code_bound( + Python::attach(|py| { + let parser = PyModule::from_code( py, - r#" + c" from prometheus_client.openmetrics.parser import text_string_to_metric_families def parse(input): families = text_string_to_metric_families(input) list(families) -"#, - "parser.py", - "parser", +", + c"parser.py", + c"parser", ) .map_err(|e| e.to_string()) .unwrap(); diff --git a/src/metrics/counter.rs b/src/metrics/counter.rs index 7016c36..c4cecd2 100644 --- a/src/metrics/counter.rs +++ b/src/metrics/counter.rs @@ -265,7 +265,7 @@ mod tests { // Map infinite, subnormal and NaN to 0.0. .map(|f| if f.is_normal() { f } else { 0.0 }) .collect(); - let sum = fs.iter().sum(); + let sum: f64 = fs.iter().sum(); let counter = Counter::::default(); for f in fs { counter.inc_by(f);