Apply review suggestions

This commit is contained in:
Tim Robinson 2021-05-15 10:33:17 +01:00
parent 735a9a1156
commit 50352f9137
3 changed files with 4 additions and 14 deletions

View File

@ -44,7 +44,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Deprecate `#[name = "..."]` attributes in favor of `#[pyo3(name = "...")]`. [#1567](https://github.com/PyO3/pyo3/pull/1567)
- Improve compilation times for projects using PyO3 [#1604](https://github.com/PyO3/pyo3/pull/1604)
### Removed
- Remove deprecated exception names `BaseException` etc. [#1426](https://github.com/PyO3/pyo3/pull/1426)
- Remove deprecated redundant methods `Python::is_instance`, `Python::is_subclass`, `Python::release`, `Python::xdecref`, and `Py::from_owned_ptr_or_panic`. [#1426](https://github.com/PyO3/pyo3/pull/1426)

View File

@ -175,15 +175,6 @@ where
value.convert(py)
}
#[doc(hidden)]
#[inline]
pub fn callback_error<T>() -> T
where
T: PyCallbackOutput,
{
T::ERR_VALUE
}
/// Use this macro for all internal callback functions which Python will call.
///
/// It sets up the GILPool and converts the output into a Python object. It also restores
@ -258,7 +249,7 @@ where
{
let py_result = match panic_result {
Ok(py_result) => py_result,
Err(panic_err) => Err(PanicException::from_panic(panic_err)),
Err(payload) => Err(PanicException::from_panic_payload(payload)),
};
py_result.unwrap_or_else(|py_err| {

View File

@ -16,10 +16,10 @@ pyo3_exception!(
impl PanicException {
// Try to format the error in the same way panic does
pub(crate) fn from_panic(e: Box<dyn Any + Send + 'static>) -> PyErr {
if let Some(string) = e.downcast_ref::<String>() {
pub(crate) fn from_panic_payload(payload: Box<dyn Any + Send + 'static>) -> PyErr {
if let Some(string) = payload.downcast_ref::<String>() {
Self::new_err((string.clone(),))
} else if let Some(s) = e.downcast_ref::<&str>() {
} else if let Some(s) = payload.downcast_ref::<&str>() {
Self::new_err((s.to_string(),))
} else {
Self::new_err(("panic from Rust code",))