def stackToList(stack):
if isinstance(stack, types.TracebackType):<EOL><INDENT>while stack.tb_next:<EOL><INDENT>stack = stack.tb_next<EOL><DEDENT>stack = stack.tb_frame<EOL><DEDENT>out = []<EOL>while stack:<EOL><INDENT>out.append(stack)<EOL>stack = stack.f_back<EOL><DEDENT>return out<EOL>
Convert a chain of traceback or frame objects into a list of frames.