On Sep 9, 2009, at 10:05 AM, Lisandro Dalcin wrote:

> On Wed, Sep 9, 2009 at 1:53 PM, Robert
> Bradshaw<[email protected]> wrote:
>> On Jul 13, 2009, at 3:35 PM, Eric Eisner wrote:
>>
>>>>> udata = <unsigned char*><char*>pydata
>>>>>
>> so the double cast above seems
>> like the right thing to do (the first cast extracts the string data,
>> the second changes the pointer type).
>
> However, if 'pydata' has embed null characters, the conversion will
> fail. I think that the only reasonable way to handle 'bytes' ('str' in
> Py2) is by using PyBytes_AsStringAndSize() (PyString_AsStringAndSize()
> in Py2)... whithout the buffer size, a buffer with embed null
> characters is useless.

Here we are going from python to C. Yes, if there are null characters  
than the length needs to be determined otherwise, and the conversion  
to Python via one of the Py*_AsAndSize methods.

- Robert

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to