try:
    foo()
except AssertionError as e:
    import inspect
previous_trace = inspect.trace()[1]
frame = previous_trace[0]
print('value of a, b:', inspect.getargvalues(frame).locals)
Re-inspection of values in a Traceback