PyString_FromString and Binary Data

gbgbgb at gmx.de gbgbgb at gmx.de
Sun Apr 29 14:47:44 EDT 2001


Hi!

I am programming a python extension in C and I am doing this:

...
L = PyString_FromString(buffer);
free(buffer);
return (PyObject *)L;

The buffer contains some ZEROs and back in Python the return-value of 
my function is truncated.

Is there any way to tell the PyString_FromString-Function not to 
truncate on ZEROs or is there some better way??
Is it OK to free the buffer or does it Python for me??
Is there a PyString_*-Function wich does not copy the input-string 
(buffer) to some other location but uses the input-pointer "in 
place"?? (The buffer gets copied and there is the memory wasted!)

thanks!
Gunter






More information about the Python-list mailing list