#NEWLINE# def chop_traceback( tb , exclude_prefix = _UNITTEST_RE , exclude_suffix = _SQLA_RE ) : #NEWLINE# #INDENT# 'Chop extraneous lines off beginning and end of a traceback.\n\n    :param tb:\n      a list of traceback lines as returned by ``traceback.format_stack()``\n\n    :param exclude_prefix:\n      a regular expression object matching lines to skip at beginning of\n      ``tb``\n\n    :param exclude_suffix:\n      a regular expression object matching lines to skip at end of ``tb``\n    ' #NEWLINE# start = 0 #NEWLINE# end = ( len ( tb ) - 1 ) #NEWLINE# while ( ( start <= end ) and exclude_prefix . search ( tb [ start ] ) ) : #NEWLINE# #INDENT# start += 1 #NEWLINE# #UNINDENT# while ( ( start <= end ) and exclude_suffix . search ( tb [ end ] ) ) : #NEWLINE# #INDENT# end -= 1 #NEWLINE# #UNINDENT# return tb [ start : ( end + 1 ) ]