def _truncate_recursive_traceback(self, traceback):
try:<EOL><INDENT>recursionindex = traceback.recursionindex()<EOL><DEDENT>except Exception as e:<EOL><INDENT>max_frames = <NUM_LIT:10><EOL>extraline = (<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>).format(<EOL>exc_type=type(e).__name__,<EOL>exc_msg=safe_str(e),<EOL>max_frames=max_frames,<EOL>total=len(traceback),<EOL>)<EOL>traceback = traceback[:max_frames] + traceback[-max_frames:]<EOL><DEDENT>else:<EOL><INDENT>if recursionindex is not None:<EOL><INDENT>extraline = "<STR_LIT>"<EOL>traceback = traceback[: recursionindex + <NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>extraline = None<EOL><DEDENT><DEDENT>return traceback, extraline<EOL>
Truncate the given recursive traceback trying to find the starting point
of the recursion.

The detection is done by going through each traceback entry and finding the
point in which the locals of the frame are equal to the locals of a previous frame (see ``recursionindex()``.

Handle the situation where the recursion process might raise an exception (for example
comparing numpy arrays using equality raises a TypeError), in which case we do our best to
warn the user of the error and show a limited traceback.