More help with Object Caching

Brent Fulgham brent.fulgham at xpsystems.com
Wed Mar 1 12:59:21 EST 2000


> > char* newCache = malloc(length*sizeof(char));
> > strncpy(newCache, cacheable, size);
> > 
> > PyObject* test2 = PyMarshal_ReadObjectFromString(newCache, size);
> > // Fails -- test2 is NULL.
> > 
> > Can anyone suggest what I am doing wrong here? 
> 
> Thinking that a Python string (which can contain null bytes) 
> can be copied like a C string?
> 
Of course! -- memcpy does the trick.

Thanks,

-Brent




More information about the Python-list mailing list