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

Philipp Heuser philipp at achtziger.de
Fri Jan 23 16:49:32 CET 2009


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


More information about the capi-sig mailing list