-
Notifications
You must be signed in to change notification settings - Fork 6
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
Injecting foreign stack frames #18
Comments
What does "injecting" mean? Is the ability to add a frame to the top of the current stack sufficient, or do they need to inject frames into the middle of the stack? |
(I haven't looked into this so don't know the answers myself.) |
Interaction between the native Rust stack and Python stack would be challenging to solve but net a decent win for developers. I can think of at least exception tracebacks and profiling as two use cases where having Rust stack frames visible would be beneficial. I think it'd probably work with an API similar to I'm not sure what frame data would be desired other than a name. |
There are two variants to this issue. The first is creating a frame on the stack in C so that the method name, file and line number appear when an exception is thrown. This can be used when enterring foreign code to indicate the location. The second variation is one in which the user has an exception in another language with a backtrace in the form of a list of object that can be converted to method name, file and line numbers. Jpype has code for this case in which we convert the objects into a python exception that is the added as a cause. Currently this is very inefficient because python frames are concrete so we have to convert even if the user never traverses the list (as opposed to when the user accesses the list). I understand there would be a speed penality to lazy allocation so not much we can do here. But if you assume exceptions should be exceptional it is fine. |
Language wrappers like JPype and Cython could use first-class support for injecting “foreign” stack frames/traceback entries.
See python/cpython#86784
The text was updated successfully, but these errors were encountered: