Try except - bug?

Askari 9974331 at cvm.qc.ca
Tue Dec 30 12:18:08 EST 2003


9974331 at cvm.qc.ca (Askari) wrote in 
news:104c369a.0312300851.4f23759e at posting.google.com:

> Hi,
>    I have a problem with try except :
> example
> ============
> try:
>     print "bou!"
>     raise "ha!"
> except:
>     try:
>         fileDest.close()
>     except NameError:
>      print "error"
>     except:
>         import traceback
>         traceback.print_exc(file=sys.stdout)
> ============
> If I run this example alone, I have no problem :
> result
> ============
> bou!
> error
> ============
> 
> but I can't understand why doesn't work in my program :
>          http://www.cvm.qc.ca/9974331/Temp/crypte.py 
> (too long for a copy and paste)
> (note : it's at line 353)
> (note : the language of this program is in french, sorry)
> 
> when I run my program, I have this error :
> ============
> Traceback (most recent call last):
>   File "C:\Documents and Settings\Assembleur_Man\Bureau\Crypte.py",
> line 355, in crypte
>     fileDest.close()
> NameError: global name 'fileDest' is not defined
> ============
> 
> but I know that 'fileDest' is not always defined but I put this line
> in a try-except!?  :-(  :-S
> 
> 
> Askari
> 


Ops! For test (to do the error), you must click on button "crypter!" with 
blank textField





More information about the Python-list mailing list