On Dec 17, 6:42 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
> En Wed, 17 Dec 2008 21:35:04 -0200, Floris Bruynooghe  
> <floris.bruynoo...@gmail.com> escribió:
> Yes; but you don't have to dig into the implementation; from  
> http://docs.python.org/c-api/arg.html:
>
> s (string or Unicode object) [const char *]
> Convert a Python string or Unicode object to a C pointer to a character  
> string. You must not provide storage for the string itself; a pointer to  
> an existing string is stored into the character pointer variable whose  
> address you pass.
>
> > But how can python now know how long to keep that buffer object in
> > memory for?
>
> It doesn't - *you* have to ensure that the original string object isn't  
> destroyed (by example, incrementing its reference count as long as you  
> keep the pointer), or copy the string contents into your own buffer.

I missed something.  How did you get a reference to the original
string object, with which to increment its reference count?  How do
you know its length to copy it into your own buffer?

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to