def _save_traceback(self, error_info):
    try:
        from os.path import exists
        filename = next((fname for n in count() for fname in [(('traceback-%d.txt' % n) if n else 'traceback.txt')] if (not exists(fname))))
        with open(filename, 'w') as outf:
            outf.write(error_info)
        self.message(('Traceback saved as %s.' % filename), title='Success')
    except Exception:
        from traceback import format_exception
        io_tb_txt = ''.join(format_exception(*sys.exc_info()))
        self.message(('An error occurred while trying to write the traceback:\n\n' + io_tb_txt), title='I/O error')
def _save_traceback(self, error_info):
    try:
        from os.path import exists
        filename = next((fname for n in count() for fname in [(('traceback-%d.txt' % n) if n else 'traceback.txt')] if (not exists(fname))))
        with open(filename, 'w') as outf:
            outf.write(error_info)
        self.message(('Traceback saved as %s.' % filename), title='Success')
    except Exception:
        from traceback import format_exception
        io_tb_txt = .join(format_exception(*sys.exc_info()))
        self.message(('An error occurred while trying to write the traceback:\n\n' + io_tb_txt), title='I/O error')