J
John Hunter
What is the best way to get the traceback as a string. I tried
def exception_to_str(s = None):
sh = StringIO.StringIO()
if s is not None: print >>sh, s
traceback.print_stack(sh)
return sh.getvalue()
but got
Traceback (most recent call last):
File "/home/jdhunter/seizure/python/eegdb/eegview/eegview.py", line 944, in on_menuFileOpen_activate
msg = exception_to_str('Could not read data:')
File "/hunter/jdhunter/python/projects/jdh/jdh/cbook.py", line 707, in exception_to_str
traceback.print_stack(sh)
File "/usr/local/lib/python2.3/traceback.py", line 235, in print_stack
print_list(extract_stack(f, limit), file)
File "/usr/local/lib/python2.3/traceback.py", line 266, in extract_stack
lineno = f.f_lineno
Thanks!
John Hunter
def exception_to_str(s = None):
sh = StringIO.StringIO()
if s is not None: print >>sh, s
traceback.print_stack(sh)
return sh.getvalue()
but got
Traceback (most recent call last):
File "/home/jdhunter/seizure/python/eegdb/eegview/eegview.py", line 944, in on_menuFileOpen_activate
msg = exception_to_str('Could not read data:')
File "/hunter/jdhunter/python/projects/jdh/jdh/cbook.py", line 707, in exception_to_str
traceback.print_stack(sh)
File "/usr/local/lib/python2.3/traceback.py", line 235, in print_stack
print_list(extract_stack(f, limit), file)
File "/usr/local/lib/python2.3/traceback.py", line 266, in extract_stack
lineno = f.f_lineno
Thanks!
John Hunter