webassembly/objpyproxy: Avoid throwing on symbol or iterator has-check.
JavaScript code uses "Symbol in object" to brand check its own proxies, and such checks should also work on the Python side. Signed-off-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
This commit is contained in:
parent
16f9d7fdc3
commit
e33a0f4682
3 changed files with 10 additions and 0 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
false
|
||||
true
|
||||
false
|
||||
true
|
||||
|
|
|
|||
Loading…
Reference in a new issue