#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 returns a string. Copied here for Python 2.3 compatibility.""" try: etype, value, tb = sys.exc_info() return ''.join(traceback.format_exception(etype, value, tb, limit)) finally: etype = value = tb = None def format_exc_mud(limit=None): """Skips intermediate lines caused by lambdadized MudObject functions.""" try: etype, value, tb = sys.exc_info() excList = traceback.format_exception(etype, value, tb, limit) excList = [excStr for excStr in excList if not((excStr.find("in __call__") != -1) and (excStr.find("return self.func(*args, **kwargs)") != -1))] return ''.join(excList) finally: etype = value = tb = None def mud_traceback(mudWorld): mudWorld.mudTraceback.reverse() returnStr = "".join(("".join(mudWorld.mudTraceback), format_exc_mud())) mudWorld.mudTraceback = [] return returnStr