You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The C++ custom exception handler is almost certainly an advanced feature to help a small number of users, but it doesn't seem like it's particularly easy to use (see discussion in #5334).
One of the obvious issues is that it's hard to extend the default Cython behaviour - you basically need to replace it or duplicate a bunch of Cython utility code yourself.
Describe the solution you'd like.
My proposal was:
make it so that __Pyx_CppExn2PyErr is always generated for users generating custom exception handlers, so that they're able to call it manually themselves if they want.
expose __Pyx_CppExn2PyErr as a callable attribute of the cython module, so it's usable from Cython code too. I'm not sure how useful that's likely to be, but it gives options.
(we'd obviously also want to generate something so that it doesn't give unused code errors).
This at least would make it easier to add to the default Cython behaviour.
Describe alternatives you've considered.
I haven't really considered... to be honest, I don't have a huge understanding of how people are using these custom exception handlers, so suggestions are welcome.
One thing I could imagine being useful (but don't know how/if we'd want to expose it) is the C++11 standard library https://en.cppreference.com/w/cpp/error/make_exception_ptr. Potentially that'd give a way for someone to stash a C++ exception in a cdef class so that it could be converted back to a C++ exception later.
Additional context
No response
The text was updated successfully, but these errors were encountered:
I definitely like the idea of that function always being generated so that custom exception handlers can call it. That can only be a helpful addition IMO.
I'm having a bit of trouble wrapping my head around how exactly this would get used since I feel like any practical use case of a custom exception handler would require custom C++ code anyway in order to add new exceptions, but maybe there is a way to make use of this.
I agree, I don't have a great idea of how people are currently using this feature, if at all. The one other case that is familiar to me is something that @pentschev worked on for ucxx, which can be seen here, but that is ultimately very similar to what I'm doing myself. It would certainly be nice to know what others are doing, if anything. @shwina may have more ideas.
When I first started implementing a prototype of this, I don't even think the possibility of introducing a custom handler was in the documentation, and I found it by trawling through the Cython source code, so at least the situation has already improved since then even prior to #5334!
Is your feature request related to a problem? Please describe.
The C++ custom exception handler is almost certainly an advanced feature to help a small number of users, but it doesn't seem like it's particularly easy to use (see discussion in #5334).
One of the obvious issues is that it's hard to extend the default Cython behaviour - you basically need to replace it or duplicate a bunch of Cython utility code yourself.
Describe the solution you'd like.
My proposal was:
__Pyx_CppExn2PyErr
is always generated for users generating custom exception handlers, so that they're able to call it manually themselves if they want.__Pyx_CppExn2PyErr
as a callable attribute of the cython module, so it's usable from Cython code too. I'm not sure how useful that's likely to be, but it gives options.(we'd obviously also want to generate something so that it doesn't give unused code errors).
This at least would make it easier to add to the default Cython behaviour.
Describe alternatives you've considered.
I haven't really considered... to be honest, I don't have a huge understanding of how people are using these custom exception handlers, so suggestions are welcome.
One thing I could imagine being useful (but don't know how/if we'd want to expose it) is the C++11 standard library
https://en.cppreference.com/w/cpp/error/make_exception_ptr
. Potentially that'd give a way for someone to stash a C++ exception in a cdef class so that it could be converted back to a C++ exception later.Additional context
No response
The text was updated successfully, but these errors were encountered: