parameters: (etype, value, records)
return_statement: return last_unique, longest_repeat
docstring: Identify the repeating stack frames from a RecursionError traceback
  
      'records' is a list as returned by VerboseTB.get_records()
  
      Returns (last_unique, repeat_length)
docstring_summary: Identify the repeating stack frames from a RecursionError traceback
docstring_tokens: Identify the repeating stack frames from a RecursionError traceback
function: def find_recursion(etype, value, records):
      """Identify the repeating stack frames from a RecursionError traceback
  
      'records' is a list as returned by VerboseTB.get_records()
  
      Returns (last_unique, repeat_length)
      """
      # This involves a bit of guesswork - we want to show enough of the traceback
      # to indicate where the recursion is occurring. We guess that the innermost
      # quarter of the traceback (250 frames by default) is repeats, and find the
      # first frame (from in to out) that looks different.
      if not is_recursion_error(etype, value, records):
          return len(records), 0
  
      # Select filename, lineno, func_name to track frames with
      records = [r[1:4] for r in records]
      inner_frames = records[-(len(records)//4):]
      frames_repeated = set(inner_frames)
  
      last_seen_at = {}
      longest_repeat = 0
      i = len(records)
      for frame in reversed(records):
          i -= 1
          if frame not in frames_repeated:
              last_unique = i
              break
  
          if frame in last_seen_at:
              distance = last_seen_at[frame] - i
              longest_repeat = max(longest_repeat, distance)
  
          last_seen_at[frame] = i
      else:
          last_unique = 0 # The whole traceback was recursion
  
      return last_unique, longest_repeat
function_tokens: def find_recursion ( etype , value , records ) : # This involves a bit of guesswork - we want to show enough of the traceback # to indicate where the recursion is occurring. We guess that the innermost # quarter of the traceback (250 frames by default) is repeats, and find the # first frame (from in to out) that looks different. if not is_recursion_error ( etype , value , records ) : return len ( records ) , 0 # Select filename, lineno, func_name to track frames with records = [ r [ 1 : 4 ] for r in records ] inner_frames = records [ - ( len ( records ) // 4 ) : ] frames_repeated = set ( inner_frames ) last_seen_at = { } longest_repeat = 0 i = len ( records ) for frame in reversed ( records ) : i -= 1 if frame not in frames_repeated : last_unique = i break if frame in last_seen_at : distance = last_seen_at [ frame ] - i longest_repeat = max ( longest_repeat , distance ) last_seen_at [ frame ] = i else : last_unique = 0 # The whole traceback was recursion return last_unique , longest_repeat