[capi-sig] Strange Python behaviour after C-Function
ggpolo at gmail.com
Fri Jan 23 19:39:10 CET 2009
On Fri, Jan 23, 2009 at 1:49 PM, Philipp Heuser <philipp at achtziger.de> wrote:
> Hi all,
> thanks for the numerous replies to my previous questions.
> Everything in C works fine so far, but there is a very strange behaviour in
> python after visiting the C-Function.
> The return value of my C-Function is a list of floats. I can print that
> list, I can do:
> while a<len(list):
> print list[a]
> works fine, but if try to do
> for element in list:
> print element
> It does that as well, but as soon as the end of the list is reached, I do
> get an IndexError: list assignment index is out of range.
> Surprisingly I do get that as well with any list, where I try to use the for
> loop after using the C-function. So if I use an arbitrary list like
> for l in ll:
> print l
> I do get the same error, and I don't before calling the C-function...
> Does that sound familiar to anybody?
It sounds like you are not being careful when coding the C function,
maybe you forgot to clear some exception or maybe it was supposed to
raise an exception but didn't. Can you paste its code ?
> Is that caused by one of the
> decref/incref things?
> Kind regards
-- Guilherme H. Polo Goncalves
More information about the capi-sig