"Memory could not be Read/Written" crashes with C extension DLL... HELP PLEASE!
Brian Quinlan
brian at sweetapp.com
Sat Apr 6 13:57:19 EST 2002
> What is the difference though, shouldn't the code below work too? Is
> there maybe something wrong in the PyTuple code? (As mentioned
> before, it only crashed when called multiple times (40+ usually), but
> worked fine otherwise.
PyTuple_SetItem does not increment the reference count of the object.
That's exactly what you want for pLong* but probably not for inBuffer
(you didn't show enough code for me to be sure).
You should develop with a debug version of Python. That way you will see
the reference count after each command you type in the interactive
shell.
Cheers,
Brian
>
> > // build pp1, inBufferSize, pp3 into PyObjects for returning
> > pLong1 = PyLong_FromLong(pp1);
> > pLong2 = PyLong_FromLong(inBufferSize);
> > pLong3 = PyLong_FromLong(pp3);
> >
> > // build pLong1, pLong2, pLong3, pString into a tuple to return
> >
> > pReturn = PyTuple_New(4);
> > PyTuple_SetItem(pReturn, 0, pLong1);
> > PyTuple_SetItem(pReturn, 1, pLong2);
> > PyTuple_SetItem(pReturn, 2, pLong3);
> > PyTuple_SetItem(pReturn, 3, inBuffer);
> >
> > return pReturn;
> > }
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list