Closed GoogleCodeExporter closed 9 years ago
Looks like it's a type conversion problem. If key in returned object is not a
number -
no exception raised.
Original comment by gauss...@gmail.com
on 12 Jan 2010 at 6:24
Original comment by flier...@gmail.com
on 13 Jan 2010 at 9:23
The root cause is that Javascript will performs automatic type conversion as
needed.
It means, the object that you return will contain two number key, when PyV8
fetch the
key with "for k in obj.__members__", the key '1' will return as number 1, and
the
convert function will use number 1 as key to call obj.__getattr__ will cause
the
crash.
So, one workaround is to force convert function use string as key, like
def convert(obj):
if type(obj) == _PyV8.JSArray:
return [convert(v) for v in obj]
if type(obj) == _PyV8.JSObject:
return dict([[str(k), convert(obj.__getattr__(str(k)))] for k in
obj.__members__])
return obj
and wait v8 API to provide full supports, because it only support the string
version
Object::Has method
// TODO(1245389): Replace the type-specific versions of these
// functions with generic ones that accept a Handle<Value> key.
bool Has(Handle<String> key);
Please check verify the code from SVN after r204, Thanks
Original comment by flier...@gmail.com
on 13 Jan 2010 at 10:18
It's ok now, thank you.
Original comment by gauss...@gmail.com
on 13 Jan 2010 at 9:32
Thanks
Original comment by flier...@gmail.com
on 14 Jan 2010 at 2:14
Original issue reported on code.google.com by
gauss...@gmail.com
on 12 Jan 2010 at 6:07