code: def rewrite_traceback_stack(source=None):
      """Rewrite the current exception to replace any tracebacks from
      within compiled template code with tracebacks that look like they
      came from the template source.
  
      This must be called within an ``except`` block.
  
      :param exc_info: A :meth:`sys.exc_info` tuple. If not provided,
          the current ``exc_info`` is used.
      :param source: For ``TemplateSyntaxError``, the original source if
          known.
      :return: A :meth:`sys.exc_info` tuple that can be re-raised.
      """
      exc_type, exc_value, tb = sys.exc_info()
  
      if (
          isinstance(exc_value, TemplateSyntaxError)
          and not exc_value.translated
      ):
          exc_value.translated = True
          exc_value.source = source
  
          try:
              # Remove the old traceback on Python 3, otherwise the frames
              # from the compiler still show up.
              exc_value.with_traceback(None)
          except AttributeError:
              pass
  
          # Outside of runtime, so the frame isn't executing template
          # code, but it still needs to point at the template.
          tb = fake_traceback(
              exc_value,
              None,
              exc_value.filename or "<unknown>",
              exc_value.lineno,
          )
      else:
          # Skip the frame for the render function.
          tb = tb.tb_next
  
      stack = []
  
      # Build the stack of traceback object, replacing any in template
      # code with the source file and line information.
      while tb is not None:
          # Skip frames decorated with @internalcode. These are internal
          # calls that aren't useful in template debugging output.
          if tb.tb_frame.f_code in internal_code:
              tb = tb.tb_next
              continue
  
          template = tb.tb_frame.f_globals.get("__jinja_template__")
  
          if template is not None:
              lineno = template.get_corresponding_lineno(tb.tb_lineno)
              fake_tb = fake_traceback(
                  exc_value, tb, template.filename, lineno
              )
              stack.append(fake_tb)
          else:
              stack.append(tb)
  
          tb = tb.tb_next
  
      tb_next = None
  
      # Assign tb_next in reverse to avoid circular references.
      for tb in reversed(stack):
          tb_next = tb_set_next(tb, tb_next)
  
      return exc_type, exc_value, tb_next
  
file_path: catboost/contrib/python/Jinja2/py2/jinja2/debug.py
imports: import sys
  from types import CodeType
  from .None import TemplateSyntaxError
  from ._compat import PYPY
  from .utils import internal_code
  from .utils import missing
label_desc: Use image node_id 1 for calling a global function with example usage: rewrite_traceback_stack(source) and returns: exc_type,  exc_value,  tb_next