Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ports/webassembly/objpyproxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ const py_proxy_handler = {
};
},
has(target, prop) {
// avoid throwing on `Symbol() in proxy` checks
if (typeof prop !== "string") {
// returns true only on iterator because other
// symbols are not considered in the `get` trap
return prop === Symbol.iterator;
}
return Module.ccall(
"proxy_c_to_js_has_attr",
"number",
Expand Down
2 changes: 2 additions & 0 deletions tests/ports/webassembly/py_proxy_has.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ x = []
const x = mp.globals.get("x");
console.log("no_exist" in x);
console.log("sort" in x);
console.log(Symbol.toStringTag in x);
console.log(Symbol.iterator in x);
2 changes: 2 additions & 0 deletions tests/ports/webassembly/py_proxy_has.mjs.exp
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
false
true
false
true
Loading