class_docstr: An exception ready for rendering.
  
  The traceback module captures enough attributes from the original exception
  to this intermediary form to ensure that no references are held, while
  still being able to fully print or format it.
  
  max_group_width and max_group_depth control the formatting of exception
  groups. The depth refers to the nesting level of the group, and the width
  refers to the size of a single exception group's exceptions array. The
  formatted output is truncated when either limit is exceeded.
  
  Use `from_exception` to create TracebackException instances from exception
  objects, or the constructor to create TracebackException instances from
  individual components.
  
  - :attr:`__cause__` A TracebackException of the original *__cause__*.
  - :attr:`__context__` A TracebackException of the original *__context__*.
  - :attr:`exceptions` For exception groups - a list of TracebackException
    instances for the nested *exceptions*.  ``None`` for other exceptions.
  - :attr:`__suppress_context__` The *__suppress_context__* value from the
    original exception.
  - :attr:`stack` A `StackSummary` representing the traceback.
  - :attr:`exc_type` The class of the original traceback.
  - :attr:`filename` For syntax errors - the filename where the error
    occurred.
  - :attr:`lineno` For syntax errors - the linenumber where the error
    occurred.
  - :attr:`end_lineno` For syntax errors - the end linenumber where the error
    occurred. Can be `None` if not present.
  - :attr:`text` For syntax errors - the text where the error
    occurred.
  - :attr:`offset` For syntax errors - the offset into the text where the
    error occurred.
  - :attr:`end_offset` For syntax errors - the end offset into the text where
    the error occurred. Can be `None` if not present.
  - :attr:`msg` For syntax errors - the compiler error message.
class_docstr_tok: ["An","exception","ready","for","rendering",".","The","traceback","module","captures","enough","attributes","from","the","original","exception","to","this","intermediary","form","to","ensure","that","no","references","are","held",",","while","still","being","able","to","fully","print","or","format","it",".","max_group_width","and","max_group_depth","control","the","formatting","of","exception","groups",".","The","depth","refers","to","the","nesting","level","of","the","group",",","and","the","width","refers","to","the","size","of","a","single","exception","group","'s","exceptions","array",".","The","formatted","output","is","truncated","when","either","limit","is","exceeded",".","Use","`","from_exception","`","to","create","TracebackException","instances","from","exception","objects",",","or","the","constructor","to","create","TracebackException","instances","from","individual","components",".","-",":","attr",":","`","__cause__","`","A","TracebackException","of","the","original","*","__cause__","*",".","-",":","attr",":","`","__context__","`","A","TracebackException","of","the","original","*","__context__","*",".","-",":","attr",":","`","exceptions","`","For","exception","groups","-","a","list","of","TracebackException","instances","for","the","nested","*","exceptions","*",".","``","None","``","for","other","exceptions",".","-",":","attr",":","`","__suppress_context__","`","The","*","__suppress_context__","*","value","from","the","original","exception",".","-",":","attr",":","`","stack","`","A","`","StackSummary","`","representing","the","traceback",".","-",":","attr",":","`","exc_type","`","The","class","of","the","original","traceback",".","-",":","attr",":","`","filename","`","For","syntax","errors","-","the","filename","where","the","error","occurred",".","-",":","attr",":","`","lineno","`","For","syntax","errors","-","the","linenumber","where","the","error","occurred",".","-",":","attr",":","`","end_lineno","`","For","syntax","errors","-","the","end","linenumber","where","the","error","occurred",".","Can","be","`","None","`","if","not","present",".","-",":","attr",":","`","text","`","For","syntax","errors","-","the","text","where","the","error","occurred",".","-",":","attr",":","`","offset","`","For","syntax","errors","-","the","offset","into","the","text","where","the","error","occurred",".","-",":","attr",":","`","end_offset","`","For","syntax","errors","-","the","end","offset","into","the","text","where","the","error","occurred",".","Can","be","`","None","`","if","not","present",".","-",":","attr",":","`","msg","`","For","syntax","errors","-","the","compiler","error","message","."]
docstr: Format the exception.
  
  If chain is not *True*, *__cause__* and *__context__* will not be formatted.
  
  The return value is a generator of strings, each ending in a newline and
  some containing internal newlines. `print_exception` is a wrapper around
  this method which just prints the lines to a file.
  
  The message indicating which exception occurred is always the last
  string in the output.
code: def format(self, *, chain=True, _ctx=None):
      """Format the exception.
  
      If chain is not *True*, *__cause__* and *__context__* will not be formatted.
  
      The return value is a generator of strings, each ending in a newline and
      some containing internal newlines. `print_exception` is a wrapper around
      this method which just prints the lines to a file.
  
      The message indicating which exception occurred is always the last
      string in the output.
      """
  
      if _ctx is None:
          _ctx = _ExceptionPrintContext()
  
      output = []
      exc = self
      if chain:
          while exc:
              if exc.__cause__ is not None:
                  chained_msg = _cause_message
                  chained_exc = exc.__cause__
              elif (
                  exc.__context__ is not None
                  and not exc.__suppress_context__
              ):
                  chained_msg = _context_message
                  chained_exc = exc.__context__
              else:
                  chained_msg = None
                  chained_exc = None
  
              output.append((chained_msg, exc))
              exc = chained_exc
      else:
          output.append((None, exc))
  
      for msg, exc in reversed(output):
          if msg is not None:
              yield from _ctx.emit(msg)
          if exc.exceptions is None:
              if exc.stack:
                  yield from _ctx.emit(
                      "Traceback (most recent call last):\n"
                  )
                  yield from _ctx.emit(exc.stack.format())
              yield from _ctx.emit(exc.format_exception_only())
          elif _ctx.exception_group_depth > self.max_group_depth:
              # exception group, but depth exceeds limit
              yield from _ctx.emit(
                  f"... (max_group_depth is {self.max_group_depth})\n"
              )
          else:
              # format exception group
              is_toplevel = _ctx.exception_group_depth == 0
              if is_toplevel:
                  _ctx.exception_group_depth += 1
  
              if exc.stack:
                  yield from _ctx.emit(
                      "Exception Group Traceback (most recent call last):\n",
                      margin_char="+" if is_toplevel else None,
                  )
                  yield from _ctx.emit(exc.stack.format())
  
              yield from _ctx.emit(exc.format_exception_only())
              num_excs = len(exc.exceptions)
              if num_excs <= self.max_group_width:
                  n = num_excs
              else:
                  n = self.max_group_width + 1
              _ctx.need_close = False
              for i in range(n):
                  last_exc = i == n - 1
                  if last_exc:
                      # The closing frame may be added by a recursive call
                      _ctx.need_close = True
  
                  if self.max_group_width is not None:
                      truncated = i >= self.max_group_width
                  else:
                      truncated = False
                  title = f"{i+1}" if not truncated else "..."
                  yield (
                      _ctx.indent()
                      + ("+-" if i == 0 else "  ")
                      + f"+---------------- {title} ----------------\n"
                  )
                  _ctx.exception_group_depth += 1
                  if not truncated:
                      yield from exc.exceptions[i].format(
                          chain=chain, _ctx=_ctx
                      )
                  else:
                      remaining = num_excs - self.max_group_width
                      plural = "s" if remaining > 1 else ""
                      yield from _ctx.emit(
                          f"and {remaining} more exception{plural}\n"
                      )
  
                  if last_exc and _ctx.need_close:
                      yield (
                          _ctx.indent()
                          + "+------------------------------------\n"
                      )
                      _ctx.need_close = False
                  _ctx.exception_group_depth -= 1
  
              if is_toplevel:
                  assert _ctx.exception_group_depth == 1
                  _ctx.exception_group_depth = 0
  
imports: import collections.abc
  import itertools
  import linecache
  import sys
  import textwrap
  from contextlib import suppress
label_desc: Use image node_id 8 for calling the TracebackException obj's underlying member method code with example usage: obj.format() without return types