kostyll / python-spidermonkey

Automatically exported from code.google.com/p/python-spidermonkey
GNU General Public License v2.0
0 stars 0 forks source link

Weird string behavior when passed to python #17

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Call a python function from the JavaScript with a string parameter 
containing null terminators

What is the expected output? What do you see instead?
Since Python and JavaScript are languages that treat strings like objects with 
length attribute, and they both totally ignore all null terminators, when 
passing a string from JS to python I expect the whole string to be copied, even 
if it has null or other control characters in the middle.
Instead, when I pass a string with null character in the middle it stops 
copying at the first null terminator, as if it was copied with strcpy.
The string built-in length attribute was ignored.

What version of the product are you using? On what operating system?
latest on Ubuntu 10

Please provide any additional information below.
This behavior also makes it impossible to pass a buffer of bytes from JS to 
python in a fast way, since Byte array is not supported.

Original issue reported on code.google.com by RonenN...@gmail.com on 22 May 2013 at 6:31