Closed GoogleCodeExporter closed 8 years ago
Original comment by flier...@gmail.com
on 16 Mar 2011 at 6:28
The root cause is pyv8 used __dict__ to enumerate the object properties.
Now, I changed it to use dir() function, which will return all the properties
including the _prop1, prop1 and getProp1 method except the name which
starts/end with '__' like __getattr__, I think it may make sense because
Javascript did the similar behaviors
Please verify the issue with SVN r356 or later, thanks
Original comment by flier...@gmail.com
on 16 Mar 2011 at 5:15
I am also seeing these methods showing up in the for/in loop.
hasOwnProperty
isPrototypeOf
toLocaleString
toString
unwatch
valueOf
watch
Typically you won't see those in native JS:
import PyV8
class NewObject(PyV8.JSClass):
def __init__(self):
pass
class Global(PyV8.JSClass):
def __init__(self):
self.newObj = NewObject()
def write(self, val):
print val
with PyV8.JSContext(Global()) as ctx:
ctx.eval("""
for(i in newObj) {
write(i)
}
""")
Output Is:
hasOwnProperty
isPrototypeOf
toLocaleString
toString
unwatch
valueOf
watch
vs. Native JS (SpiderMonkey Shell):
js> x = {}
[object Object]
js> x.a = 10
10
js> for(i in x) { print(i) }
a
js> x.toString()
[object Object]
js>
Original comment by ATM1...@gmail.com
on 16 Mar 2011 at 8:56
Original issue reported on code.google.com by
ATM1...@gmail.com
on 15 Mar 2011 at 7:01