-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented Error trait for PyErr #126
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should remove that err.rs.swp
src/err.rs
Outdated
@@ -394,6 +396,21 @@ impl <'p> std::convert::From<PythonObjectDowncastError<'p>> for PyErr { | |||
} | |||
} | |||
|
|||
impl Error for PyErr { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✂️
src/err.rs
Outdated
} | ||
|
||
impl fmt::Display for PyErr { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✂️
Fixed |
Waiting for this to be merged. Is it because Travis failed? Seems like it cannot compile some test - but this seems to not be caused by this PR (?) |
I sync'd my branch with master and it appears to have fixed the error with the doctest however there is a new error with nightly. Not really sure what is causing it. |
|
||
impl fmt::Display for PyErr { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "PyErr: ptype {:?} pvalue {:?}", self.ptype, self.pvalue) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect Display to result in something like str(e)
in Python.
This code here is more like repr(type(e))
+ repr(e)
, except even weirder if the exception is not yet initialized (PyErr::new_lazy_init
).
This allows for more flexibility for converting between error types.
Relevant issue: #125