Skip to content

Conversation

@dpgeorge
Copy link
Member

@dpgeorge dpgeorge commented May 9, 2024

There are three fixes here:

  • Support more than 4 args when JS calls a Python function.
  • Fix case where a Promise is resolved with no argument.
  • Ensure objects thrown into generators are Python exceptions.

@dpgeorge dpgeorge force-pushed the webassembly-add-js-exception branch from 373e529 to fb4cde3 Compare May 9, 2024 05:21
@dpgeorge dpgeorge added this to the release-1.23.0 milestone May 9, 2024
@codecov
Copy link

codecov bot commented May 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.39%. Comparing base (cc3550e) to head (fa23e4b).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #14457   +/-   ##
=======================================
  Coverage   98.39%   98.39%           
=======================================
  Files         161      161           
  Lines       21204    21204           
=======================================
  Hits        20864    20864           
  Misses        340      340           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

dpgeorge added 4 commits May 13, 2024 11:48
Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
This commit defines a new `JsException` exception type which is used on the
Python side to wrap JavaScript errors.  That's then used when a JavaScript
Promise is rejected, and the reason is then converted to a `JsException`
for the Python side to handle.

This new exception is exposed as `jsffi.JsException`.

Signed-off-by: Damien George <damien@micropython.org>
And change Py None conversion so it converts to JS undefined.

The semantics for conversion of these objects are then:
- Python None           -> JavaScript undefined
- JavaScript undefined  -> Python None
- JavaScript null       -> Python None

This follows Pyodide:
https://pyodide.org/en/stable/usage/type-conversions.html

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge dpgeorge force-pushed the webassembly-add-js-exception branch from fb4cde3 to fa23e4b Compare May 13, 2024 01:54
@dpgeorge dpgeorge merged commit fa23e4b into micropython:master May 13, 2024
@dpgeorge dpgeorge deleted the webassembly-add-js-exception branch May 13, 2024 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant