Is there any way to hide portions of an exception stack trace? When users get exceptions when using pyparsing, there are usually many layers of pyparsing-internal stack messages that are not at all helpful in diagnosing the problem - the intervening messages just divert the user's attention from the most significant parts of the stack, usually the user's call into my module, and the root exception message. For instance, here is a stack trace:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/site-packages/pyparsing.py", line 1065, in parseString loc, tokens = self._parse( instring, 0 ) File "/usr/lib/python2.5/site-packages/pyparsing.py", line 998, in _parseCache value = self._parseNoCache( instring, loc, doActions, callPreParse ) File "/usr/lib/python2.5/site-packages/pyparsing.py", line 941, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "/usr/lib/python2.5/site-packages/pyparsing.py", line 2577, in parseImpl return self.expr._parse( instring, loc, doActions, callPreParse=False ) File "/usr/lib/python2.5/site-packages/pyparsing.py", line 998, in _parseCache value = self._parseNoCache( instring, loc, doActions, callPreParse ) File "/usr/lib/python2.5/site-packages/pyparsing.py", line 941, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "/usr/lib/python2.5/site-packages/pyparsing.py", line 2325, in parseImpl loc, exprtokens = e._parse( instring, loc, doActions ) File "/usr/lib/python2.5/site-packages/pyparsing.py", line 998, in _parseCache value = self._parseNoCache( instring, loc, doActions, callPreParse ) File "/usr/lib/python2.5/site-packages/pyparsing.py", line 941, in _parseNoCache loc,tokens = self.parseImpl( instring, preloc, doActions ) File "/usr/lib/python2.5/site-packages/pyparsing.py", line 2577, in parseImpl return self.expr._parse( instring, loc, doActions, callPreParse=False ) File "/usr/lib/python2.5/site-packages/pyparsing.py", line 998, in _parseCache value = self._parseNoCache( instring, loc, doActions, callPreParse ) File "/usr/lib/python2.5/site-packages/pyparsing.py", line 943, in _parseNoCache raise ParseException( instring, len(instring), self.errmsg, self ) pyparsing.ParseException: Expected ")" (at char 82), (line:1, col:83) The only helpful content here is just this much: Traceback (most recent call last): File "<stdin>", line 1, in <module> pyparsing.ParseException: Expected ")" (at char 82), (line:1, col:83) That is, the point in the program where the user's code called parseString, and the exception raised deep down in the recursive parser that determined there was a missing closing paren in the input string being parsed. Is there any way for me to suppress these non-value-added API-internal traceback levels? -- Paul -- http://mail.python.org/mailman/listinfo/python-list