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

Simplify FromPyPointer #781

Closed
davidhewitt opened this issue Mar 1, 2020 · 3 comments
Closed

Simplify FromPyPointer #781

davidhewitt opened this issue Mar 1, 2020 · 3 comments

Comments

@davidhewitt
Copy link
Member

davidhewitt commented Mar 1, 2020

There are so many methods in this trait. Is there a reason why we don't just have

unsafe fn from_owned_ptr(py: Python<'p>, ptr: *mut ffi::PyObject) -> PyResult<&'p Self>;
unsafe fn from_borrowed_ptr(py: Python<'p>, ptr: *mut ffi::PyObject) -> PyResult<&'p Self>;

As the only trait method. And then just let users choose if they want to .ok(), .unwrap(), or .expect() this, instead of all the _or_opt, _or_panic etc.

Originally posted by @davidhewitt in #770

@kngwyu
Copy link
Member

kngwyu commented Mar 2, 2020

We use a special panic implementation that calls ffi::PyErr_Print so I'd rather remove only from_owned_ptr_or_opt.

@davidhewitt
Copy link
Member Author

Ok. I think after #492 is addressed we will probably find that the custom panic implementation is not necessary. So let's wait with this until #492 is done.

@davidhewitt
Copy link
Member Author

FromPyPointer has been removed with the GIL Refs.

@davidhewitt davidhewitt closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants