[Tutor] Runtime Errors

shendric@arches.uga.edu shendric@arches.uga.edu
Mon, 17 Jun 2002 10:36:57 -0500


Hi, 

Thanks for the response.  Sorry to just be replying.  Been out of email 
range for the weekend.  Anyway, I took your advice and eliminated the 
try-except pairs, using the traceback function, instead.  I still get 
the error, but here's the full error output:

  File "C:\Documents and 
Settings\Administrator\Desktop\VTrans\AudioTranscriber2.py", line 239, 
in ?
    root.mainloop()
  File "C:\Python22\lib\lib-tk\Tkinter.py", line 929, in mainloop
    self.tk.mainloop(n)
  File "C:\PYTHON22\Pmw\Pmw_0_8_5\lib\PmwBase.py", line 1694, in 
__call__
    _reporterror(self.func, args)
  File "C:\PYTHON22\Pmw\Pmw_0_8_5\lib\PmwBase.py", line 1741, in 
_reporterror
    for tr in traceback.extract_tb(exc_traceback):
RuntimeError: maximum recursion depth exceeded

Sean

---------Included Message----------
>Date: Fri, 14 Jun 2002 23:53:18 -0700 (PDT)
>From: "Danny Yoo" <dyoo@hkn.eecs.berkeley.edu>
>To: <shendric@ARCHES.UGA.EDU>
>Cc: "Python Tutor" <tutor@python.org>
>Subject: Re: [Tutor] Runtime Errors
>
>
>
>On Fri, 14 Jun 2002 shendric@arches.uga.edu wrote:
>
>> I've got a script I'm working on that is a kind of spreadsheet.  
There
>> are a fixed number of 4 cells in each row, but the idea would be to 
have
>> as many rows as one wishes.  The algorithm for the spreadsheet works
>> fine, but I get a RuntimeError when I try to load a tab-delimited 
text
>> file into the cells.
>>
>> The loading algorithm is this:
>>
>> 1. Open a text file
>> 2. Read the lines of the text file into a list (readlines())
>> 3. Take each line and do the following:
>>     a. create an instance of the TranscriptionCell class, which is a
>> class that includes four Tkinter Pmw.ScrolledText widgets
>>     b. append that instance to a list
>>     c. put the contents of the first part of the line into the first
>> text widget, then the second into the second, etc.
>> 4.  close the file
>
>Sounds reasonable enough.  Yes, this should work.
>
>>
>> I get the following error:
>> RuntimeError: maximum recursion depth exceeded
>
>
>Hmmm... does the error message also give a clue in which function, and
>around which line it goes bonkers?
>
>
>> Now, I've gotten it to go just fine with only a few rows, but not if
>> there are a lot of them.
>
>
>We'll have to look through the code to see where the recursion's 
coming
>from.  Reading... hmmm...  It might not be such a good idea to wrap 
every
>statement with exception handling like:
>
>###
>             try:
>                self.rowlist[ind].TTime.settext(rowcontents[0])
>             except:
>                 pass
>             try:
>                self.rowlist[ind].TSpeak.settext(rowcontents[1])
>             except:
>                 pass
>###
>
>Doing just a 'pass' when an exception occurs is like an ostrich that 
puts
>its head in the sand:  We're ignoring any potentially bad problems!  
If
>the first row setting fails, it's probable that the whole rowcontents 
list
>has some weirdness that should be reported to the user.
>
>
>
>To make this function easier to debug, we can strip out some of the
>exception handling code, and put a traceback.print_exc() call in the 
code:
>
>###
>def openTrans(self, event=None):
>   file = askopenfile(title="Open Transcript File",
>                      filetypes=(("text files", "*.txt"),
>                                 ("All files", "*")))
>   filetoread = open(file.name, 'r')
>   filecontents = filetoread.readlines()
>   filetoread.close()
>   ind = 0
>   self.rowlist=[]
>   for x in filecontents:
>       rowcontents = x.split("\t")
>       self.rowlist.append(TranscriptionCell(self.inner,
>                                             row=self.row))
>       try:
>           self.rowlist[ind].TTime.settext(rowcontents[0])
>           self.rowlist[ind].TSpeak.settext(rowcontents[1])
>           self.rowlist[ind].TTrans.textBox.settext(rowcontents[2])
>           self.rowlist[ind].Comments.settext(rowcontents[3])
>       except:
>           traceback.print_exc()
>       self.row = self.row + 1
>       ind = ind + 1
>###
>
>
>The traceback.print_exc() should tell us if there's something else 
that's
>going weird.  Hmmm.... but I don't see any obvious recursion here.  
Can
>you show the last few previous lines of the error message as well?  
It'll
>help us to find where exactly the recursion is occuring.
>
>
>Sounds like a tricky bug, but don't worry, we're bound to squish it.
>*grin* Talk to you later!
>
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
---------End of Included Message----------