-
Couldn't load subscription status.
- Fork 135
Implemented Error trait for PyErr #126
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,8 @@ use std::ptr; | |
| use libc::c_char; | ||
| use conversion::ToPyObject; | ||
| use std::ffi::CString; | ||
| use std::error::Error; | ||
| use std::fmt; | ||
|
|
||
| /** | ||
| Defines a new exception type. | ||
|
|
@@ -394,6 +396,21 @@ impl <'p> std::convert::From<PythonObjectDowncastError<'p>> for PyErr { | |
| } | ||
| } | ||
|
|
||
| impl Error for PyErr { | ||
|
|
||
| fn description(&self) -> &str { | ||
| "Error originating from the rust-cpython bindings." | ||
| } | ||
|
|
||
| } | ||
|
|
||
| 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 commentThe reason will be displayed to describe this comment to others. Learn more. I would expect Display to result in something like |
||
| } | ||
| } | ||
|
|
||
| /// Construct PyObject from the result of a Python FFI call that returns a new reference (owned pointer). | ||
| /// Returns `Err(PyErr)` if the pointer is `null`. | ||
| /// Unsafe because the pointer might be invalid. | ||
|
|
||
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.
✂️