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

Technical post about exception handling in Pyodide's ffi #43

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hoodmane
Copy link
Member

@hoodmane hoodmane commented Apr 3, 2024

No description provided.

Copy link

netlify bot commented Apr 3, 2024

Deploy Preview for pyodide-blog ready!

Name Link
🔨 Latest commit ef67220
🔍 Latest deploy log https://app.netlify.com/sites/pyodide-blog/deploys/660dbc71b0e3710008b7b538
😎 Deploy Preview https://deploy-preview-43--pyodide-blog.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hoodmane hoodmane requested review from rth and ryanking13 April 3, 2024 20:32
Copy link
Member

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hoodmane! It was very fun to read. Probably this post is not very easy to read for those who are not familiar with both languages and its internals, but it would be very helpful for some people who are interested in Pyodide internals and future contributors.

The contents of the post generally looks good to me. I left some minor comments.

setPythonErrorFromJsError(e); \
return -1; \
} \
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't highlighted pretty when rendered:

image

```
and making these replacements breaks some JavaScript code. We need a version of
these macros that works equally well in both C and JavaScript. Since `!!1`
evaluates to `true` in JavaScript and `1` in C, the following definitions work
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow didn't know about this... it is really tricky to deal with C macros :)


## Implementing `setPythonErrorFromJsError`

We can call C functions from JavaScript with an extra leading `_`. A simplified
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was because Emscripten put the underscore prefix, right? I guess we should mention that why there is leading underscore.


## Conclusion

??? What should we say here?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe adding some future plans or briefly mentioning some weird cases that are not handled in this post (c++ exceptions?) would be nice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants