diff --git a/src/pyproxy.c b/src/pyproxy.c index 1ad05583b..43fd6b61a 100644 --- a/src/pyproxy.c +++ b/src/pyproxy.c @@ -142,6 +142,12 @@ EM_JS(int, pyproxy_init, (), { isPyProxy: function(jsobj) { return jsobj['$$'] !== undefined && jsobj['$$']['type'] === 'PyProxy'; }, + addExtraKeys: function(result) { + result.push('toString'); + result.push('prototype'); + result.push('arguments'); + result.push('caller'); + }, isExtensible: function() { return true }, has: function (jsobj, jskey) { ptrobj = this.getPtr(jsobj); @@ -197,8 +203,7 @@ EM_JS(int, pyproxy_init, (), { var idresult = __pyproxy_ownKeys(ptrobj); var jsresult = Module.hiwire_get_value(idresult); Module.hiwire_decref(idresult); - jsresult.push('toString'); - jsresult.push('prototype'); + this.addExtraKeys(jsresult); return jsresult; }, enumerate: function (jsobj) { @@ -206,8 +211,7 @@ EM_JS(int, pyproxy_init, (), { var idresult = __pyproxy_enumerate(ptrobj); var jsresult = Module.hiwire_get_value(idresult); Module.hiwire_decref(idresult); - jsresult.push('toString'); - jsresult.push('prototype'); + this.addExtraKeys(jsresult); return jsresult; }, apply: function (jsobj, jsthis, jsargs) { diff --git a/test/test_python.py b/test/test_python.py index 5d61dc7a8..d47fc20ed 100644 --- a/test/test_python.py +++ b/test/test_python.py @@ -125,7 +125,7 @@ def test_pyproxy(selenium): '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'bar', 'baz', - 'get_value', 'toString', 'prototype']) + 'get_value', 'toString', 'prototype', 'arguments', 'caller']) assert selenium.run("hasattr(f, 'baz')") selenium.run_js("delete pyodide.pyimport('f').baz") assert not selenium.run("hasattr(f, 'baz')")