Skip to content

Commit e26e857

Browse files
authored
fix build warnings on python <3.11 (#1259)
1 parent 970c6e5 commit e26e857

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/errors/validation_exception.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl ValidationError {
145145
use pyo3::exceptions::PyUserWarning;
146146

147147
let wrapped = PyUserWarning::new_err((note,));
148-
wrapped.set_cause(py, Some(PyErr::from_value(err.as_ref(py))));
148+
wrapped.set_cause(py, Some(PyErr::from_value_bound(err.clone_ref(py).into_bound(py))));
149149
user_py_errs.push(wrapped);
150150
}
151151
}
@@ -167,16 +167,16 @@ impl ValidationError {
167167
#[cfg(not(Py_3_11))]
168168
let cause = {
169169
use pyo3::exceptions::PyImportError;
170-
match py.import("exceptiongroup") {
171-
Ok(py_mod) => match py_mod.getattr("ExceptionGroup") {
172-
Ok(group_cls) => match group_cls.call1((title, user_py_errs)) {
173-
Ok(group_instance) => Some(group_instance.into_py(py)),
170+
match py.import_bound("exceptiongroup") {
171+
Ok(py_mod) => match py_mod.getattr("ExceptionGroup") {
172+
Ok(group_cls) => match group_cls.call1((title, user_py_errs)) {
173+
Ok(group_instance) => Some(group_instance.into_py(py)),
174+
Err(_) => None,
175+
},
174176
Err(_) => None,
175177
},
176-
Err(_) => None,
177-
},
178-
Err(_) => return Some(PyImportError::new_err("validation_error_cause flag requires the exceptiongroup module backport to be installed when used on Python <3.11.")),
179-
}
178+
Err(_) => return Some(PyImportError::new_err("validation_error_cause flag requires the exceptiongroup module backport to be installed when used on Python <3.11.")),
179+
}
180180
};
181181

182182
// Set the cause to the ValidationError:

0 commit comments

Comments
 (0)