add PyErr to io::Error convert
This commit is contained in:
parent
ffe774a8cc
commit
8ccb749c1e
|
@ -394,6 +394,14 @@ impl <'p> std::convert::From<PythonObjectDowncastError<'p>> for PyErr {
|
|||
}
|
||||
}
|
||||
|
||||
/// Convert PyErr to io::Error
|
||||
impl std::convert::From<PyErr> for std::io::Error {
|
||||
fn from(err: PyErr) -> Self {
|
||||
std::io::Error::new(
|
||||
std::io::ErrorKind::Other, format!("Python exception: {:?}", err))
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct PyObject from the result of a Python FFI call that returns a new reference (owned pointer).
|
||||
/// Returns `Err(PyErr)` if the pointer is `null`.
|
||||
/// Unsafe because the pointer might be invalid.
|
||||
|
|
|
@ -29,7 +29,9 @@ macro_rules! py_class_init_properties {
|
|||
|
||||
$type_object.tp_getset =
|
||||
props.as_ptr() as *mut $crate::_detail::ffi::PyGetSetDef;
|
||||
std::mem::forget(props);
|
||||
|
||||
use std::mem;
|
||||
mem::forget(props);
|
||||
}};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue