Skip to content

Make it easy to convert Rust error types to Python exceptions #21

Closed
@messense

Description

@messense
error[E0277]: the trait bound `pyo3::PyErr: std::convert::From<std::io::Error>` is not satisfied
  --> src/lib.rs:11:17
   |
11 |     let mut f = fs::File::open(path)?;
   |                 ^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<std::io::Error>` is not implemented for `pyo3::PyErr`
   |
   = help: the following implementations were found:
             <pyo3::PyErr as std::convert::From<pyo3::PyDowncastError<'p>>>
   = note: required by `std::convert::From::from`

This is annoying, makes it hard to use try! or ?. We could implement From trait for some of the Rust error types like std::io::Error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions