{
    "content": [
        {
            "type": "text",
            "text": "# traceback (pydoc)\n\n**Summary:** traceback - Extract, format and print information about Python stack traces.\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **MODULE REFERENCE** (8 lines)\n- **CLASSES** (6 lines) — 3 subsections\n  - class FrameSummary (59 lines)\n  - class StackSummary (184 lines)\n  - class TracebackException (88 lines)\n- **FUNCTIONS** (1 lines) — 16 subsections\n  - clear_frames (2 lines)\n  - extract_stack (8 lines)\n  - extract_tb (11 lines)\n  - format_exc (2 lines)\n  - format_exception (8 lines)\n  - format_exception_only (12 lines)\n  - format_list (11 lines)\n  - format_stack (2 lines)\n  - format_tb (2 lines)\n  - print_exc (2 lines)\n  - print_exception (10 lines)\n  - print_last (3 lines)\n  - print_stack (6 lines)\n  - print_tb (7 lines)\n  - walk_stack (5 lines)\n  - walk_tb (5 lines)\n- **DATA** (2 lines)\n- **FILE** (3 lines)\n\n## Full Content\n\n### NAME\n\ntraceback - Extract, format and print information about Python stack traces.\n\n### MODULE REFERENCE\n\nhttps://docs.python.org/3.10/library/traceback.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n\n### CLASSES\n\nbuiltins.list(builtins.object)\nStackSummary\nbuiltins.object\nFrameSummary\nTracebackException\n\n#### class FrameSummary\n\n|  FrameSummary(filename, lineno, name, *, lookupline=True, locals=None, line=None)\n|\n|  A single frame from a traceback.\n|\n|  - :attr:`filename` The filename for the frame.\n|  - :attr:`lineno` The line within filename for the frame that was\n|    active when the frame was captured.\n|  - :attr:`name` The name of the function or method that was executing\n|    when the frame was captured.\n|  - :attr:`line` The text from the linecache module for the\n|    of code that was running when the frame was captured.\n|  - :attr:`locals` Either None if locals were not supplied, or a dict\n|    mapping the name to the repr() of the variable.\n|\n|  Methods defined here:\n|\n|  eq(self, other)\n|      Return self==value.\n|\n|  getitem(self, pos)\n|\n|  init(self, filename, lineno, name, *, lookupline=True, locals=None, line=None)\n|      Construct a FrameSummary.\n|\n|      :param lookupline: If True, `linecache` is consulted for the source\n|          code line. Otherwise, the line will be looked up when first needed.\n|      :param locals: If supplied the frame locals, which will be captured as\n|          object representations.\n|      :param line: If provided, use this instead of looking up the line in\n|          the linecache.\n|\n|  iter(self)\n|\n|  len(self)\n|\n|  repr(self)\n|      Return repr(self).\n|\n|  ----------------------------------------------------------------------\n|  Readonly properties defined here:\n|\n|  line\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  filename\n|\n|  lineno\n|\n|  locals\n|\n|  name\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  hash = None\n\n#### class StackSummary\n\n|  StackSummary(iterable=(), /)\n|\n|  A stack of frames.\n|\n|  Method resolution order:\n|      StackSummary\n|      builtins.list\n|      builtins.object\n|\n|  Methods defined here:\n|\n|  format(self)\n|      Format the stack ready for printing.\n|\n|      Returns a list of strings ready for printing.  Each string in the\n|      resulting list corresponds to a single frame from the stack.\n|      Each string ends in a newline; the strings may contain internal\n|      newlines as well, for those items with source text lines.\n|\n|      For long sequences of the same frame and line, the first few\n|      repetitions are shown, followed by a summary line stating the exact\n|      number of further repetitions.\n|\n|  ----------------------------------------------------------------------\n|  Class methods defined here:\n|\n|  extract(framegen, *, limit=None, lookuplines=True, capturelocals=False) from builtins.type\n|      Create a StackSummary from a traceback or stack object.\n|\n|      :param framegen: A generator that yields (frame, lineno) tuples to\n|          include in the stack.\n|      :param limit: None to include all frames or the number of frames to\n|          include.\n|      :param lookuplines: If True, lookup lines for each frame immediately,\n|          otherwise lookup is deferred until the frame is rendered.\n|      :param capturelocals: If True, the local variables from each frame will\n|          be captured as object representations into the FrameSummary.\n|\n|  fromlist(alist) from builtins.type\n|      Create a StackSummary object from a supplied list of\n|      FrameSummary objects or old-style list of tuples.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.list:\n|\n|  add(self, value, /)\n|      Return self+value.\n|\n|  contains(self, key, /)\n|      Return key in self.\n|\n|  delitem(self, key, /)\n|      Delete self[key].\n|\n|  eq(self, value, /)\n|      Return self==value.\n|\n|  ge(self, value, /)\n|      Return self>=value.\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  getitem(...)\n|      x.getitem(y) <==> x[y]\n|\n|  gt(self, value, /)\n|      Return self>value.\n|\n|  iadd(self, value, /)\n|      Implement self+=value.\n|\n|  imul(self, value, /)\n|      Implement self*=value.\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  iter(self, /)\n|      Implement iter(self).\n|\n|  le(self, value, /)\n|      Return self<=value.\n|\n|  len(self, /)\n|      Return len(self).\n|\n|  lt(self, value, /)\n|      Return self<value.\n|\n|  mul(self, value, /)\n|      Return self*value.\n|\n|  ne(self, value, /)\n|      Return self!=value.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  reversed(self, /)\n|      Return a reverse iterator over the list.\n|\n|  rmul(self, value, /)\n|      Return value*self.\n|\n|  setitem(self, key, value, /)\n|      Set self[key] to value.\n|\n|  sizeof(self, /)\n|      Return the size of the list in memory, in bytes.\n|\n|  append(self, object, /)\n|      Append object to the end of the list.\n|\n|  clear(self, /)\n|      Remove all items from list.\n|\n|  copy(self, /)\n|      Return a shallow copy of the list.\n|\n|  count(self, value, /)\n|      Return number of occurrences of value.\n|\n|  extend(self, iterable, /)\n|      Extend list by appending elements from the iterable.\n|\n|  index(self, value, start=0, stop=9223372036854775807, /)\n|      Return first index of value.\n|\n|      Raises ValueError if the value is not present.\n|\n|  insert(self, index, object, /)\n|      Insert object before index.\n|\n|  pop(self, index=-1, /)\n|      Remove and return item at index (default last).\n|\n|      Raises IndexError if list is empty or index is out of range.\n|\n|  remove(self, value, /)\n|      Remove first occurrence of value.\n|\n|      Raises ValueError if the value is not present.\n|\n|  reverse(self, /)\n|      Reverse *IN PLACE*.\n|\n|  sort(self, /, *, key=None, reverse=False)\n|      Sort the list in ascending order and return None.\n|\n|      The sort is in-place (i.e. the list itself is modified) and stable (i.e. the\n|      order of two equal elements is maintained).\n|\n|      If a key function is given, apply it once to each list item and sort them,\n|      ascending or descending, according to their function values.\n|\n|      The reverse flag can be set to sort in descending order.\n|\n|  ----------------------------------------------------------------------\n|  Class methods inherited from builtins.list:\n|\n|  classgetitem(...) from builtins.type\n|      See PEP 585\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.list:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes inherited from builtins.list:\n|\n|  hash = None\n\n#### class TracebackException\n\n|  TracebackException(exctype, excvalue, exctraceback, *, limit=None, lookuplines=True, capturelocals=False, compact=False, seen=None)\n|\n|  An exception ready for rendering.\n|\n|  The traceback module captures enough attributes from the original exception\n|  to this intermediary form to ensure that no references are held, while\n|  still being able to fully print or format it.\n|\n|  Use `fromexception` to create TracebackException instances from exception\n|  objects, or the constructor to create TracebackException instances from\n|  individual components.\n|\n|  - :attr:`cause` A TracebackException of the original *cause*.\n|  - :attr:`context` A TracebackException of the original *context*.\n|  - :attr:`suppresscontext` The *suppresscontext* value from the\n|    original exception.\n|  - :attr:`stack` A `StackSummary` representing the traceback.\n|  - :attr:`exctype` The class of the original traceback.\n|  - :attr:`filename` For syntax errors - the filename where the error\n|    occurred.\n|  - :attr:`lineno` For syntax errors - the linenumber where the error\n|    occurred.\n|  - :attr:`endlineno` For syntax errors - the end linenumber where the error\n|    occurred. Can be `None` if not present.\n|  - :attr:`text` For syntax errors - the text where the error\n|    occurred.\n|  - :attr:`offset` For syntax errors - the offset into the text where the\n|    error occurred.\n|  - :attr:`endoffset` For syntax errors - the end offset into the text where\n|    the error occurred. Can be `None` if not present.\n|  - :attr:`msg` For syntax errors - the compiler error message.\n|\n|  Methods defined here:\n|\n|  eq(self, other)\n|      Return self==value.\n|\n|  init(self, exctype, excvalue, exctraceback, *, limit=None, lookuplines=True, capturelocals=False, compact=False, seen=None)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  str(self)\n|      Return str(self).\n|\n|  format(self, *, chain=True)\n|      Format the exception.\n|\n|      If chain is not *True*, *cause* and *context* will not be formatted.\n|\n|      The return value is a generator of strings, each ending in a newline and\n|      some containing internal newlines. `printexception` is a wrapper around\n|      this method which just prints the lines to a file.\n|\n|      The message indicating which exception occurred is always the last\n|      string in the output.\n|\n|  formatexceptiononly(self)\n|      Format the exception part of the traceback.\n|\n|      The return value is a generator of strings, each ending in a newline.\n|\n|      Normally, the generator emits a single string; however, for\n|      SyntaxError exceptions, it emits several lines that (when\n|      printed) display detailed information about where the syntax\n|      error occurred.\n|\n|      The message indicating which exception occurred is always the last\n|      string in the output.\n|\n|  ----------------------------------------------------------------------\n|  Class methods defined here:\n|\n|  fromexception(exc, *args, kwargs) from builtins.type\n|      Create a TracebackException from an exception.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  hash = None\n\n### FUNCTIONS\n\n#### clear_frames\n\nClear all references to local variables in the frames of a traceback.\n\n#### extract_stack\n\nExtract the raw traceback from the current stack frame.\n\nThe return value has the same format as for extracttb().  The\noptional 'f' and 'limit' arguments have the same meaning as for\nprintstack().  Each item in the list is a quadruple (filename,\nline number, function name, text), and the entries are in order\nfrom oldest to newest stack frame.\n\n#### extract_tb\n\nReturn a StackSummary object representing a list of\npre-processed entries from traceback.\n\nThis is useful for alternate formatting of stack traces.  If\n'limit' is omitted or None, all entries are extracted.  A\npre-processed stack trace entry is a FrameSummary object\ncontaining attributes filename, lineno, name, and line\nrepresenting the information that is usually printed for a stack\ntrace.  The line is a string with leading and trailing\nwhitespace stripped; if the source is not available it is None.\n\n#### format_exc\n\nLike printexc() but return a string.\n\n#### format_exception\n\nFormat a stack trace and the exception information.\n\nThe arguments have the same meaning as the corresponding arguments\nto printexception().  The return value is a list of strings, each\nending in a newline and some containing internal newlines.  When\nthese lines are concatenated and printed, exactly the same text is\nprinted as does printexception().\n\n#### format_exception_only\n\nFormat the exception part of a traceback.\n\nThe return value is a list of strings, each ending in a newline.\n\nNormally, the list contains a single string; however, for\nSyntaxError exceptions, it contains several lines that (when\nprinted) display detailed information about where the syntax\nerror occurred.\n\nThe message indicating which exception occurred is always the last\nstring in the list.\n\n#### format_list\n\nFormat a list of tuples or FrameSummary objects for printing.\n\nGiven a list of tuples or FrameSummary objects as returned by\nextracttb() or extractstack(), return a list of strings ready\nfor printing.\n\nEach string in the resulting list corresponds to the item with the\nsame index in the argument list.  Each string ends in a newline;\nthe strings may contain internal newlines as well, for those items\nwhose source text line is not None.\n\n#### format_stack\n\nShorthand for 'formatlist(extractstack(f, limit))'.\n\n#### format_tb\n\nA shorthand for 'formatlist(extracttb(tb, limit))'.\n\n#### print_exc\n\nShorthand for 'printexception(*sys.excinfo(), limit, file)'.\n\n#### print_exception\n\nPrint exception up to 'limit' stack trace entries from 'tb' to 'file'.\n\nThis differs from printtb() in the following ways: (1) if\ntraceback is not None, it prints a header \"Traceback (most recent\ncall last):\"; (2) it prints the exception type and value after the\nstack trace; (3) if type is SyntaxError and value has the\nappropriate format, it prints the line where the syntax error\noccurred with a caret on the next line indicating the approximate\nposition of the error.\n\n#### print_last\n\nThis is a shorthand for 'printexception(sys.lasttype,\nsys.lastvalue, sys.lasttraceback, limit, file)'.\n\n#### print_stack\n\nPrint a stack trace from its invocation point.\n\nThe optional 'f' argument can be used to specify an alternate\nstack frame at which to start. The optional 'limit' and 'file'\narguments have the same meaning as for printexception().\n\n#### print_tb\n\nPrint up to 'limit' stack trace entries from the traceback 'tb'.\n\nIf 'limit' is omitted or None, all entries are printed.  If 'file'\nis omitted or None, the output goes to sys.stderr; otherwise\n'file' should be an open file or file-like object with a write()\nmethod.\n\n#### walk_stack\n\nWalk a stack yielding the frame and line number for each frame.\n\nThis will follow f.fback from the given frame. If no frame is given, the\ncurrent stack is used. Usually used with StackSummary.extract.\n\n#### walk_tb\n\nWalk a traceback yielding the frame and line number for each frame.\n\nThis will follow tb.tbnext (and thus is in the opposite order to\nwalkstack). Usually used with StackSummary.extract.\n\n### DATA\n\nall = ['extractstack', 'extracttb', 'formatexception', 'format...\n\n### FILE\n\n/usr/lib/python3.10/traceback.py\n\n"
        }
    ],
    "structuredContent": {
        "command": "traceback",
        "section": "",
        "mode": "pydoc",
        "summary": "traceback - Extract, format and print information about Python stack traces.",
        "synopsis": null,
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "MODULE REFERENCE",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "CLASSES",
                "lines": 6,
                "subsections": [
                    {
                        "name": "class FrameSummary",
                        "lines": 59
                    },
                    {
                        "name": "class StackSummary",
                        "lines": 184
                    },
                    {
                        "name": "class TracebackException",
                        "lines": 88
                    }
                ]
            },
            {
                "name": "FUNCTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "clear_frames",
                        "lines": 2
                    },
                    {
                        "name": "extract_stack",
                        "lines": 8
                    },
                    {
                        "name": "extract_tb",
                        "lines": 11
                    },
                    {
                        "name": "format_exc",
                        "lines": 2
                    },
                    {
                        "name": "format_exception",
                        "lines": 8
                    },
                    {
                        "name": "format_exception_only",
                        "lines": 12
                    },
                    {
                        "name": "format_list",
                        "lines": 11
                    },
                    {
                        "name": "format_stack",
                        "lines": 2
                    },
                    {
                        "name": "format_tb",
                        "lines": 2
                    },
                    {
                        "name": "print_exc",
                        "lines": 2
                    },
                    {
                        "name": "print_exception",
                        "lines": 10
                    },
                    {
                        "name": "print_last",
                        "lines": 3
                    },
                    {
                        "name": "print_stack",
                        "lines": 6
                    },
                    {
                        "name": "print_tb",
                        "lines": 7
                    },
                    {
                        "name": "walk_stack",
                        "lines": 5
                    },
                    {
                        "name": "walk_tb",
                        "lines": 5
                    }
                ]
            },
            {
                "name": "DATA",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "FILE",
                "lines": 3,
                "subsections": []
            }
        ]
    }
}