Skip to content

Commit ebd9662

Browse files
committed
webassembly/objpyproxy: Avoid throwing on symbols or iterator.
Signed-off-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
1 parent 1b0cdc0 commit ebd9662

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

ports/webassembly/objpyproxy.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ const py_proxy_handler = {
148148
};
149149
},
150150
has(target, prop) {
151+
// avoid throwing on `Symbol() in proxy` checks
152+
if (typeof prop !== "string") {
153+
// returns true only on iterator because other
154+
// symbols are not considered in the `get` trap
155+
return prop === Symbol.iterator;
156+
}
151157
return Module.ccall(
152158
"proxy_c_to_js_has_attr",
153159
"number",

tests/ports/webassembly/py_proxy_has.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ x = []
99
const x = mp.globals.get("x");
1010
console.log("no_exist" in x);
1111
console.log("sort" in x);
12+
console.log(Symbol.toStringTag in x);
13+
console.log(Symbol.iterator in x);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
false
22
true
3+
false
4+
true

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy