# Copyright 2006-2016 Mark Diekhans from __future__ import print_function import pickle import sys import os import traceback import signal from warnings import warn def _signal_num_to_name(num): "get name for a signal number" # find name in signal namespace for key in vars(signal): if (getattr(signal, key) == num) and key.startswith("SIG") and (key.find("_") < 0): return key return "signal" + str(num) def test1(): gotEx = None try: try: raise ValueError("I am not valued") except Exception as ex: raise Exception("got one") from ex except Exception as ex2: gotEx = ex2 print("orig:", gotEx, "from", gotEx.__cause__) p = pickle.dumps(gotEx, pickle.HIGHEST_PROTOCOL) gotEx2 = pickle.loads(p) print("load:", gotEx2, "from", gotEx2.__cause__) test1()