PySequence_SetItem
Jack Diederich
jack at psynchronous.com
Wed Aug 16 17:23:06 EDT 2006
On Wed, Aug 16, 2006 at 01:45:44PM -0700, John Machin wrote:
> Bill Pursell wrote:
> > Bill Pursell wrote:
> >
> > Also note that the problem goes away if I replace
> > the call to PySequence_SetItem with:
> > PySequence_SetItem(l, 0, PyInt_FromLong(1L));
>
> Are you sure? It should make absolutely no difference.
>
> My experience so far:
> 1. crashes in call to PySequence_SetItem
> 2. removed py_DECREF, s/Sequence/List/ -> works OK
> 3. added code to test return value from PyWhatever_SetItem [you should
> *always* test for error], s/Sequence/Object/ -> PyObject_SetItem call
> returns -1, PyErr_Print -> "SystemError: null argument to internal
> routine"
Changing the PySequence_SetItem to PyList_SetItem and dropping the
DECREF works for me too (PyList functions steal a reference). I also
tried setting the list to length 1, still no dice. The PySequence
version segs under 2.4 and 2.5. It segs even when the Int is changed
to a String.
Yikes, I'll poke around some more.
-Jack
More information about the Python-list
mailing list