def _extract_traceback(text):
capture = False<EOL>entries = []<EOL>all_else = []<EOL>ignore_trace = False<EOL>if text.count(TRACEBACK_IDENTIFIER) == <NUM_LIT:2>:<EOL><INDENT>ignore_trace = True<EOL><DEDENT>for index, line in enumerate(text):<EOL><INDENT>if TRACEBACK_IDENTIFIER in line:<EOL><INDENT>if ignore_trace:<EOL><INDENT>ignore_trace = False<EOL>continue<EOL><DEDENT>capture = True<EOL><DEDENT>elif capture and line.startswith('<STR_LIT:U+0020>'):<EOL><INDENT>if index % <NUM_LIT:2> == <NUM_LIT:0>:<EOL><INDENT>line = line.strip().strip('<STR_LIT:\n>')<EOL>next_line = text[index + <NUM_LIT:1>].strip('<STR_LIT:\n>')<EOL>entries.append(line + '<STR_LIT:U+002CU+0020>' + next_line)<EOL><DEDENT><DEDENT>elif capture:<EOL><INDENT>entries.append(line)<EOL>break<EOL><DEDENT>else:<EOL><INDENT>all_else.append(line)<EOL><DEDENT><DEDENT>traceback_entries = []<EOL>for index, line in enumerate(entries[:-<NUM_LIT:2>]):<EOL><INDENT>element = line.split('<STR_LIT:U+002C>')<EOL>element[<NUM_LIT:0>] = element[<NUM_LIT:0>].strip().lstrip('<STR_LIT>').strip('<STR_LIT>')<EOL>element[<NUM_LIT:1>] = element[<NUM_LIT:1>].strip().lstrip('<STR_LIT>').strip()<EOL>element[<NUM_LIT:2>] = element[<NUM_LIT:2>].strip().lstrip('<STR_LIT>').strip()<EOL>traceback_entries.append(tuple(element))<EOL><DEDENT>return traceback_entries, all_else<EOL>
Receive a list of strings representing the input from stdin and return
    the restructured backtrace.

    This iterates over the output and once it identifies a hopefully genuine
    identifier, it will start parsing output.
    In the case the input includes a reraise (a Python 3 case), the primary
    traceback isn't handled, only the reraise.

    Each of the traceback lines are then handled two lines at a time for each
    stack object.

    Note that all parts of each stack object are stripped from newlines and
    spaces to keep the output clean.