:py:mod:`tblib` =============== .. py:module:: tblib Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 decorators/index.rst pickling_support/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: tblib.Code tblib.Frame tblib.Traceback .. py:exception:: TracebackParseError Bases: :py:obj:`Exception` Common base class for all non-exit exceptions. .. py:class:: Code(code) Class that replicates just enough of the builtin Code object to enable serialization and traceback rendering. .. py:attribute:: co_code .. py:class:: Frame(frame, *, get_locals=None) Class that replicates just enough of the builtin Frame object to enable serialization and traceback rendering. :Parameters: **get_locals** (*callable*) -- A function that take a frame argument and returns a dict. See :class:`Traceback` class for example. .. py:method:: clear() For compatibility with PyPy 3.5; clear() was added to frame in Python 3.4 and is called by traceback.clear_frames(), which in turn is called by unittest.TestCase.assertRaises .. py:class:: Traceback(tb, *, get_locals=None) Class that wraps builtin Traceback objects. :Parameters: **get_locals** (*callable*) -- A function that take a frame argument and returns a dict. Ideally you will only return exactly what you need, and only with simple types that can be json serializable. Example: .. code:: python def get_locals(frame): if frame.f_locals.get("__tracebackhide__"): return {"__tracebackhide__": True} else: return {} .. py:attribute:: tb_next .. py:attribute:: to_traceback .. py:attribute:: to_dict .. py:method:: as_traceback() Convert to a builtin Traceback object that is usable for raising or rendering a stacktrace. .. py:method:: as_dict() Converts to a dictionary representation. You can serialize the result to JSON as it only has builtin objects like dicts, lists, ints or strings. .. py:method:: from_dict(dct) :classmethod: Creates an instance from a dictionary with the same structure as ``.as_dict()`` returns. .. py:method:: from_string(string, strict=True) :classmethod: Creates an instance by parsing a stacktrace. Strict means that parsing stops when lines are not indented by at least two spaces anymore.