Skip to content

Commit

Permalink
Uses io::Error code when converting io::IntoInnerError to PyErr
Browse files Browse the repository at this point in the history
  • Loading branch information
Tpt committed Aug 17, 2023
1 parent 9363491 commit 7c366cb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions newsfragments/3396.changed.md
@@ -0,0 +1 @@
Reuses `std::io::Error` conversion code when converting `std::io::IntoInnerError` to `PyErr`
14 changes: 6 additions & 8 deletions src/err/impls.rs
Expand Up @@ -33,21 +33,19 @@ impl PyErrArguments for io::Error {
}
}

impl<W: 'static + Send + Sync + std::fmt::Debug> std::convert::From<std::io::IntoInnerError<W>>
for PyErr
{
fn from(err: std::io::IntoInnerError<W>) -> PyErr {
exceptions::PyOSError::new_err(err)
impl<W> From<io::IntoInnerError<W>> for PyErr {
fn from(err: io::IntoInnerError<W>) -> PyErr {
err.into_error().into()
}
}

impl<W: Send + Sync + std::fmt::Debug> PyErrArguments for std::io::IntoInnerError<W> {
impl<W: Send + Sync> PyErrArguments for io::IntoInnerError<W> {
fn arguments(self, py: Python<'_>) -> PyObject {
self.to_string().into_py(py)
self.into_error().arguments(py)
}
}

impl std::convert::From<std::convert::Infallible> for PyErr {
impl From<std::convert::Infallible> for PyErr {
fn from(_: std::convert::Infallible) -> PyErr {
unreachable!()
}
Expand Down

0 comments on commit 7c366cb

Please sign in to comment.