On Dec 18, 5:09 am, Ivan Illarionov <ivan.illario...@gmail.com> wrote: > On 18 ÄÅË, 03:51, Aaron Brady <castiro...@gmail.com> wrote: > (snip) > > > How did you get a reference to the original > > string object, with which to increment its reference count? > > Use the "O!" format instead of "s": > PyObject *pystr; > ... PyArg_ParseTuple(args, "O!", &PyStringObject, &pystr) ... edit: &PyString_Type > > Then you can use PyString_AS_STRING explicitly, and control ref. > counts yourself. > > > How do you know its length to copy it into your own buffer? > > Use the "s#" format, as Gabriel has said. > > Ivan
I see. Do I read correctly that 's' is only useful when the argument's position is known? Otherwise you can't know its length or change its reference count. -- http://mail.python.org/mailman/listinfo/python-list