Skip to content

Commit

Permalink
Attempt PyO3#2 - remove panic handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Nov 29, 2021
1 parent 18f260b commit 33f8658
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/callback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::{GILPool, IntoPyPointer};
use crate::{IntoPy, PyObject, Python};
use std::any::Any;
use std::os::raw::c_int;
use std::panic::{AssertUnwindSafe, UnwindSafe};
use std::{isize, panic};
use std::panic::UnwindSafe;
use std::isize;

/// A type which can be the return type of a python C-API callback
pub trait PyCallbackOutput: Copy {
Expand Down Expand Up @@ -241,15 +241,8 @@ where
R: PyCallbackOutput,
{
let pool = GILPool::new();
let unwind_safe_py = AssertUnwindSafe(pool.python());
let panic_result = panic::catch_unwind(move || -> PyResult<_> {
let py = *unwind_safe_py;
body(py)
});
if let Err(ref x) = panic_result {
eprintln!(">>> PANIC: {:?}", x);
}
panic_result_into_callback_output(pool.python(), panic_result)
let panic_result = body(pool.python());
panic_result_into_callback_output(pool.python(), Ok(panic_result))
}

fn panic_result_into_callback_output<R>(
Expand Down

0 comments on commit 33f8658

Please sign in to comment.