Merge pull request #3396 from Tpt/IntoInnerError

Uses io::Error code when converting io::IntoInnerError to PyErr
This commit is contained in:
David Hewitt 2023-08-18 08:27:35 +00:00 committed by GitHub
commit 7f32ed96db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -0,0 +1 @@
Reuses `std::io::Error` conversion code when converting `std::io::IntoInnerError` to `PyErr`

View File

@ -58,21 +58,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!()
}