Deeper tracebacks?

brooklineTom BrooklineTom at gmail.com
Wed Dec 10 19:59:16 CET 2008


I want my exception handler to report the method that originally
raised an exception, at the deepest level in the call-tree. Let give
an example.

import sys, traceback
class SomeClass:
    def error(self):
        """Raises an AttributeError exception."""
        int(3).zork()

    def perform_(self, aSelector):
        try:
            aMethod = getattr(self, aSelector, None)
            answer = apply(aMethod, [], {})
        except: AttributeError, anAttributeErrorException:
            aRawStack = traceback.extract_stack()
            answer = None

When I call "perform_" (... SomeClass().perform_('error')), I want to
collect and report the location *within the method ("error") that
failed*. The above code reports the location of "perform_", and no
deeper in the call tree.

Anybody know how to accomplish this?



More information about the Python-list mailing list