[issue45112] Python exception object is different after pickle.dumps and pickle.loads
Irit Katriel
report at bugs.python.org
Mon Sep 6 09:08:03 EDT 2021
Irit Katriel <iritkatriel at gmail.com> added the comment:
The default __reduce__ method of Exception returns the arg you pass to the Exception constructor:
>>> a = ExcA("a banana")
>>> a.__reduce__()
(<class '__main__.ExcA'>, ('missing a banana',))
>>>
This is then pickled, and when unpickled the arg is passed to the ExcA constructor.
If you want to change this, you can implement __reduce__ on ExcA o return just the part you want it to return.
----------
nosy: +iritkatriel
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45112>
_______________________________________
More information about the Python-bugs-list
mailing list