Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

asoderman
Copy link

This allows for more flexibility for converting between error types.

Relevant issue: #125

Copy link
Contributor

@Eijebong Eijebong left a 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 {

Copy link
Contributor

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 {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✂️

@asoderman
Copy link
Author

Fixed

@Ploppz
Copy link

Ploppz commented Apr 3, 2018

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 (?)

@asoderman
Copy link
Author

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)
Copy link
Owner

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants