DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Exception Frame Local Variable Values

02.01.2011
| 3382 views |
  • submit to reddit
        Returns dictionary with local variable content from frame where exception was raised

def getExceptionFrameLocals():
    retVal = {}

    if sys.exc_info():
        trace = sys.exc_info()[2]
        while trace.tb_next:
            trace = trace.tb_next
        retVal = trace.tb_frame.f_locals

    return retVal