exception problem

Chris Angelico rosuav at gmail.com
Tue Jun 26 17:36:09 EDT 2012


(You posted privately to me again; I hope you don't mind my responding
on-list as this appears to have been merely oversight.)

On Wed, Jun 27, 2012 at 5:25 AM, Charles Hixson
<charleshixsn at earthlink.net> wrote:
> Only thing is, this whole mess started when I was trying to trace down and
> expected error.  (Which turned out to be "self.chunkLine(..." where self
> wasn't defined.)  It was running without ANY error being displayed.  Though
> as I look an outer loop is inclosed in a try:except:finally:  It still has
> an unlabelled except, because I don't remember what exception is thrown when
> a file reads an unintelligible character  (i.e., it isn't really a utf-8
> file).  Currently I've fixed all the files so that they're either utf-8 or
> just ASCII, so currently it isn't getting triggered, but it's still there.
>  So that's probably the explanation.  I think I'll fix that now.  (I can, I
> guess, assume that any exception will be caught by except BasicException:)

That's the problem, your blanket try/except. Don't do it! It blinds
you. Same goes for catching Exception or BaseException. Catch what you
really need to catch, and reserve catch-all statements for special
cases where you don't have access to the console.

ChrisA



More information about the Python-list mailing list