catching all exceptions
Arne Mueller
a.mueller at icrf.icnet.uk
Thu Feb 8 11:34:00 EST 2001
More information about the Python-list mailing list
Thu Feb 8 11:34:00 EST 2001
- Previous message (by thread): catching all exceptions
- Next message (by thread): Memory leaks or other things ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Siggy Brentrup wrote: > > Sorry for the typo :-( > > Siggy Brentrup <bsb at winnegan.de> writes: > > > import traceback, cStringIO > > > > f = cStringIO.StringIO > f = cStringIO.StringIO() > > traceback.print_exc(None, f) > > > > write_to_database(f.getvalue()) > > > > HTH > > Siggy Thanks alot for the code above, this is what I was looking for. Also sorry, I should have known about the traceback module - obviously didn't read the python reference manual carefully anough ;-( here's some code to do a test: import sys, traceback, StringIO x = 5 def boo(n): x.append(n) # raises AttributeError try: boo(6) except: f = StringIO.StringIO() print "Start" traceback.print_exc(None, f) #s = f.getvalue() # this works s = f.readlines() # empty array print s f.close() print "End" f.readline() returns an empty array, but shouldn't have traceback.print_exc(None, f) filled f, so that 'readlines' can access it? thanks very much, Arne
- Previous message (by thread): catching all exceptions
- Next message (by thread): Memory leaks or other things ?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list