Skip to content

Commit

Permalink
From_pyany use Py<PyAny> instead of Bound for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dberthault committed May 2, 2024
1 parent 9cfe47d commit 4d4cb8b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions qoqo_calculator_pyo3/src/calculator_complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,12 @@ impl CalculatorComplexWrapper {
}

impl CalculatorComplexWrapper {
pub fn from_pyany(input: &Bound<PyAny>) -> PyResult<CalculatorComplex> {
convert_into_calculator_complex(input).map_err(|err| {
PyValueError::new_err(format!("Error in convert_to_calculator_complex: {err:?}"))
pub fn from_pyany(input: Py<PyAny>) -> PyResult<CalculatorComplex> {
Python::with_gil(|py| -> PyResult<CalculatorComplex> {
let input = input.bind(py);
convert_into_calculator_complex(input).map_err(|err| {
PyValueError::new_err(format!("Error in convert_to_calculator_complex: {err:?}"))
})
})
}
}
9 changes: 6 additions & 3 deletions qoqo_calculator_pyo3/src/calculator_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,12 @@ impl CalculatorFloatWrapper {
}

impl CalculatorFloatWrapper {
pub fn from_pyany(input: &Bound<PyAny>) -> PyResult<CalculatorFloat> {
convert_into_calculator_float(input).map_err(|err| {
PyValueError::new_err(format!("Error in convert_to_calculator_float: {err:?}"))
pub fn from_pyany(input: Py<PyAny>) -> PyResult<CalculatorFloat> {
Python::with_gil(|py| -> PyResult<CalculatorFloat> {
let input = input.bind(py);
convert_into_calculator_float(input).map_err(|err| {
PyValueError::new_err(format!("Error in convert_to_calculator_float: {err:?}"))
})
})
}
}

0 comments on commit 4d4cb8b

Please sign in to comment.