This repository was archived by the owner on Jan 1, 2026. It is now read-only.
Fix #63 #66, supersede #67: Wrap Python exceptions into custom InternalPythonError#79
Open
qwenger wants to merge 1 commit intoPetterS:masterfrom
Open
Fix #63 #66, supersede #67: Wrap Python exceptions into custom InternalPythonError#79qwenger wants to merge 1 commit intoPetterS:masterfrom
qwenger wants to merge 1 commit intoPetterS:masterfrom
Conversation
…ns into custom InternalPythonError object extending InternalError.
Collaborator
Author
|
The |
Collaborator
Author
|
One question is also whether we would like to expose the JS Or better yet, make JSException subclass of Object and directly encapsulate the JS error inside it? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #63, fix #66.
Supersedes #67. As proposed over there, this stores Python exception into a JS object rather than globally.
On the QuickJS side, the object uses as an opaque pointer to store the Python exception.
On the JS side, the object has constructor
InternalPythonErrorthat extendsInternalErrorand has themessageproperty set toPython call failed.On the Python side, the exception type is
JSPythonException, a subclass ofJSException. Its__cause__is set to the exception originally triggered, which is a pretty clean way to keep track of it.The code has a few "not so nice" areas, but for which I did not find anything nicer:
InternalPythonError) has to do a special check of the thread state, because it is both called from insideprepare...end_call_jsandprepare...end_call_python.InternalPythonErrorwas needed, because I did not see a way to use the parent constructor (InternalError).InternalErroris first raised, then catched directly and itsstackproperty transferred over to theInternalPythonError.