Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pickle exceptions with __context__ info #69

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/tblib/pickling_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ def pickle_traceback(tb):
return unpickle_traceback, (Frame(tb.tb_frame), tb.tb_lineno, tb.tb_next and Traceback(tb.tb_next))


def unpickle_exception(func, args, cause, tb):
def unpickle_exception(func, args, cause, context, suppress, tb):
inst = func(*args)
inst.__cause__ = cause
inst.__context__ = context
inst.__suppress_context__ = suppress
inst.__traceback__ = tb
return inst

Expand All @@ -42,7 +44,7 @@ def pickle_exception(obj):
raise TypeError("str __reduce__ output is not supported")
assert isinstance(rv, tuple) and len(rv) >= 2

return (unpickle_exception, rv[:2] + (obj.__cause__, obj.__traceback__)) + rv[2:]
return (unpickle_exception, rv[:2] + (obj.__cause__, obj.__context__, obj.__suppress_context__, obj.__traceback__)) + rv[2:]


def _get_subclasses(cls):
Expand Down