* Kent Johnson <[EMAIL PROTECTED]> [2005-04-07 15:28]:
> David Rock wrote:
> >I am trying to catch an exception from the csv module but it doesn't
> >seem to be generating a proper exception because I don't seem to be able
> >to catch it. Here is what I am doing:
> >
> >
> >for inputline in fileinput.input(args):
> >     try:
> >             input = csv.reader([inputline], escapechar='\\')
> >     except:
> >             print "ERROR", inputline
> >
> >
> >This is the traceback:
> >Traceback (most recent call last):
> >  File "/usr/openv/local/bin/bpdbreport_test.py", line 539, in ?
> >    for line in input:
> >_csv.Error: newline inside string
> 
> I'm suspicious of this - the traceback doesn't match the code you show. Is 
> your program called bpdbreport_test.py? What is happening at line 539 of 
> bpdbreport_test.py?

Line 539 is the csv.reader line. I just boiled it down to the place
where things don't make sense. I use try/except blocks all the time and
I even tested this one by putting a "raise" statement inside the block
and it picked it up, so it's not a scope issue or anything weird like
that. I think the csv module doesn't raise an exception properly. Can
someone verify that it works for them?

I am going to continue testing with an extremely watered down version to
see if it _ever_ works right.

-- 
David Rock
[EMAIL PROTECTED]

Attachment: pgpanrCj7ro4M.pgp
Description: PGP signature

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to