Try except - bug?

Askari 9974331 at cvm.qc.ca
Tue Dec 30 11:51:58 EST 2003


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




More information about the Python-list mailing list