[Tutor] IDLE Crashing

Kent Johnson kent37 at tds.net
Sat Aug 5 13:56:04 CEST 2006


Adam Gomaa wrote:
> I'm having trouble with this script. When I run it, it crashes IDLE... 
> which is no fun. :(
>
> I'm running Ubuntu 6.06 w/ python 2.4
>
> When I say crash, I mean really _crash_. IDLE stop responding, and I 
> have to killall idle && killall python2.4 before I can restart it (cause 
> python2.4 keeps the TCP port open, I'm assuming)
>
> A few notes:
> list.txt is a text file with 99 lines, each with three letters on it.
> In ./retrieves, I have 99 files of style [xyz].1.txt. (in addition to 
> list.txt) These are retrieved HTML pages that have the HTML stripped 
> (the actual script is part of a series of scripts to download and format 
> my school's course catalog)
> It seems to crash on the final iteration of the second for loop, no 
> matter what file it's on at that point (which I've changed by changing 
> x&y in 'for each in filelist[x:y]:' to diffrent values), so I don't 
> think it has anything to do with the actual files it's accessing.
>   
It looks like for some reason there is a problem with printing 
goodlist1. I can't think of why that would happen. (At first I thought, 
maybe there are special chars in the data, but printing a list prints 
the repr() of the list elements, so any special chars should be escaped. 
I also suspected the length of goodlist1 but it sounds like you have 
tried with a smaller subset of the data.)

A couple of things you could try. If you put these prints before "print 
goodlist1" it will confirm that you do exit the last loop.
# get some idea how much data is in goodlist
print len(goodlist1)
print len(repr(goodlist1))

Try running your program from the command line instead of inside IDLE.

Posting the tar file sounds like a good idea.
Kent
> -----
> #2006 Adam Gomaa, Public Domain
> listfiles=open('retrieves/list.txt','r')
> fileread=listfiles.read() ##reads list.txt and assings to fileread
> filelist=[]
> filelist=fileread.splitlines() ##each filelist word is 3-letter combo
> listfiles.close()
> count,count2=0,0 ##for debugging
> textstringlist=[]
> goodlist1=[]
> for each in filelist[:-50]: ##filelist[x:y] always crashes for any value 
> of x,y
>     print count ##for debugging
>     count=count+1
>     textfileread=open('retrieves/%s.1.txt' % each,'r')
>     textstring=textfileread.read()
>     textfileread.close()
>     each=each.upper()
>     textstringlist=textstring.split(each)##if I comment out from here...
>     for each2 in textstringlist[:]: #changing to textstringlist[3:-3] 
> still results in crash
>         count2=count2+1
>         print count2,'is count2' ##this gets quite high, into thousands, 
> before stopping on the final iteration (and crashing)
>         if 'Prerequisites' in each2:
>             goodlist1.append(each2)##to here, it doesn't crash
> print goodlist1
> ------
>
> Anyone have an insight?
> If someone would like me to I can tar the 99 files & list.txt and post a 
> link.
> Thanks,
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
>   




More information about the Tutor mailing list