Fix leak in to_js of dictionary (#4853)

This commit is contained in:
Hood Chatham 2024-06-09 09:10:44 -07:00 committed by GitHub
parent e29a300e71
commit df9d1773d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View File

@ -16,6 +16,9 @@ myst:
## Unreleased
- {{ Fix }} Don't leak the values in a dictionary when applying `to_js` to it.
{pr}`4853`
### Packages
- Upgraded `scikit-learn` to 1.5 {pr}`4823`

View File

@ -275,6 +275,7 @@ _python2js_dict(ConversionContext* context, PyObject* x)
FAIL_IF_MINUS_ONE(
context->dict_add_keyvalue(context, jsdict, jskey, jsval));
}
Py_CLEAR(item);
}
FAIL_IF_ERR_OCCURRED();
if (context->dict_postprocess) {

View File

@ -2200,3 +2200,12 @@ def test_bind_construct(selenium):
A = A.bind_sig(A_sig)
A()
@run_in_pyodide
def test_to_js_no_leak(selenium):
from js import Object
from pyodide.ffi import to_js
d = {"key": Object()}
to_js(d)