mptraceback.py
Release/mptraceback.py · 1.2 KB
From the archive MUDPyE v0.04.tar.gz
Download the archive « Back to the archive contents
#MUDPyE - (M)ulti-(U)ser (D)imension (Py)thon (E)ngine
#Copyright (C) 2005 Corey Staten
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#Send feedback/questions to MUDPyE@gmail.com
import sys
import traceback
def format_exc(limit=None):
"""Like print_exc() but return a string."""
try:
etype, value, tb = sys.exc_info()
return ''.join(traceback.format_exception(etype, value, tb, limit))
finally:
etype = value = tb = None
def mud_traceback(mudWorld):
mudWorld.mudTraceback.reverse()
returnStr = "".join(("".join(mudWorld.mudTraceback), format_exc()))
mudWorld.mudTraceback = []
return returnStr