Why can't I pickle an error's Traceback in Python?

后端 未结 3 884
猫巷女王i
猫巷女王i 2021-02-18 16:36

I\'ve since found a work around, but still want to know the answer.

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-18 17:14

    You can use tblib

        try:
            1 / 0
        except Exception as e:
             raise Exception("foo") from e
    except Exception as e:
        s = pickle.dumps(e)
    raise pickle.loads(s)
    

提交回复
热议问题