[Pyrex] Total newbie needs code review
Chris Stromberger
chris.stromberger at gmail.com
Mon Sep 12 20:52:21 CEST 2005
On 9/12/05, Chris Stromberger <chris.stromberger at gmail.com> wrote:
> On 9/12/05, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> > Chris Stromberger wrote:
> >
> > > I guess this is why pyrex says "Obtaining char * from temporary Python
> > > value" when I compile the pyx?
> >
> > Pyrex tries to save you from yourself if you do anything
> > with a string that looks blatantly dangerous, but it
> > can't tell for sure, and sometimes it errs on the side
> > of paranoia.
> >
> > If it's giving a false alarm, you should be able to
> > shut it up by assigning the offending Python string
> > to an intermediate variable before doing the char *
> > conversion.
> >
> > What code is giving this message, exactly?
> >
>
> This line, from my original example:
>
> def pyfunc(self, pyinputs):
> cdef inputs* cinputs
> cinputs.s = pyinputs.s
>
> Where inputs->s is a char* in the c struct.
>
And to further clarify, the pyinputs is a PyInputs Python object (see
original email) with those strings filled out. Here's how it is used
in the client script:
import myPyrexCreatedModule
inputs = myPyrexCreatedModule.PyInputs()
inputs.s = "some string"
...
myPyrexCreatedModule.pyfunc(inputs)
-Chris
More information about the Pyrex
mailing list