[Pyrex] How can I get Pyrex to put binary data into a Python string?

Parzival Herzog parzp at shaw.ca
Wed Feb 2 05:34:48 CET 2005


I have  some C code that produces binary data bytes at some location. The 
number of bytes is not a constant. I want to transfer this data unaltered as 
the contents of a Python string. This kind of string can be accessed later 
by, e.g. a struct.umpack(...) call.

Pyrex automatically converts a cdef char * variable to a Python string, but 
the resultiong Python string ends at the first zero byte in the buffer.  Is 
there a straightforward way in a pyrex module to transfer a binary string, 
including null characters, to a Python string?

If this is not possible directly with Pyrex, can anyone suggest a good way to 
work around that limitiation?

-- 
Parzival Herzog



More information about the Pyrex mailing list