code-google-com / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

Accessing outside the bounds of a Python array from JS raises RangeError instead of undefined #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Attached is a patch with a test case showing the problem, array3[9] ===
undefined fails and instead raises a RangeError

Original issue reported on code.google.com by sciyoshi on 3 Jan 2010 at 9:18

Attachments:

GoogleCodeExporter commented 9 years ago
The root cause is I misunderstand the javascript behavior, I have submitted the 
code 
that return undefined when array index out of range instead of raise exception.

Please check out the source code from SVN after r190 to verify it.

Thanks for your patch

Original comment by flier...@gmail.com on 4 Jan 2010 at 3:17

GoogleCodeExporter commented 9 years ago
Could you also add the case where index < 0? I don't think Javascript supports
negative indexing...

Original comment by sciyoshi on 4 Jan 2010 at 3:31

GoogleCodeExporter commented 9 years ago
v8 use uint32_t type to pass index, so I think v8 will ensure the index will 
not be negative :)

typedef unsigned int uint32_t;

v8::Handle<v8::Value> CPythonObject::IndexedGetter(
  uint32_t index, const v8::AccessorInfo& info)

Original comment by flier...@gmail.com on 4 Jan 2010 at 3:33

GoogleCodeExporter commented 9 years ago
woops, didn't see that. thanks!

Original comment by sciyoshi on 4 Jan 2010 at 4:38