poppopjmp / shedskin

Automatically exported from code.google.com/p/shedskin
0 stars 0 forks source link

invalid list.remove behavior #180

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Running this leads to segfault, but it wasn't the original full example. The 
original example was double iterating the last element when the last element of 
a list was removed.

Sample code:
============

testdellastelem = []
testdellastelem.append("test1")
testdellastelem.append("test2")
testdellastelem.append("test3")
remove=0
for v in testdellastelem:
  if (v == "test3"):
    assert remove==0
    testdellastelem.remove(v)
    remove=1

Hope it helps.
Sincerely,
Topaz

Original issue reported on code.google.com by akato...@gmail.com on 12 Feb 2013 at 3:38

GoogleCodeExporter commented 8 years ago
Oups, just remember I made a mistake, I'm removing an entry from the list I'm 
iterating on ... 
Not a bug, but python reports otherwise than a segfault.

Original comment by akato...@gmail.com on 13 Feb 2013 at 8:18

GoogleCodeExporter commented 8 years ago
thanks a lot for reporting in any case! yeah, modifying an object while 
iterating over it is tricky in different ways. but I will have a closer look at 
this particular example when I return from vacation.

Original comment by mark.duf...@gmail.com on 14 Feb 2013 at 5:59

GoogleCodeExporter commented 8 years ago
sorry it took so long before I finally had a good look at this. I wrongly 
assumed nothing could be done about the problem. in the end it worked after 
just a small change. thanks so much for reporting, and please do let me know 
when you run into anything else. 

Original comment by mark.duf...@gmail.com on 5 May 2013 at 3:33

GoogleCodeExporter commented 8 years ago
Thanks to you, ok my code is fixed to avoid this behavior, but in the
end I'm glad I helped !
Have a nice day,
Olivier.

Original comment by akato...@gmail.com on 5 May 2013 at 5:43