[capi-sig] Solved Strange Python behaviour after C-Function

Philipp Heuser philipp at achtziger.de
Fri Jan 23 17:23:44 CET 2009


Sorry for bothering you,

I just made a stupid error in C, mixing up variable names, so one of the 
returned lists had the wrong content and wrong length...
strange python behaviour anyway...

Philipp


Philipp Heuser schrieb:
> 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:
>
> a=0
> while a<len(list):
>     print list[a]
>    a=a+1
>
> 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
>
> ll=[1,2,3]
> 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? Is that caused by one of the 
> decref/incref things?
> Kind regards
> Philipp
> _______________________________________________
> capi-sig mailing list
> capi-sig at python.org
> http://mail.python.org/mailman/listinfo/capi-sig
>



More information about the capi-sig mailing list