[issue28925] Confusing exception from cPickle on reduce failure

Raoul Gough report at bugs.python.org
Thu Dec 15 05:00:56 EST 2016


Raoul Gough added the comment:

Hi Serhiy, thanks very much for looking at this. My only concern with removing the code completely is that it does work (presumably as intended) with at least some of the standard exception types. For example, if you change the demo to raise and catch a RuntimeError instead of MyException, the output looks like this:

INFO:root:Creating BadReduce object
INFO:root:Pickling
INFO:root:Unpickling
INFO:root:Raising exception "BadReduce init failed"
INFO:root:Got RuntimeError "(RuntimeError('BadReduce init failed',), <class '__main__.BadReduce'>, (1123,))"
INFO:root:Done

Where the caught RuntimeError contains the original RuntimeError and some additional information from cPickle.

I also checked that it correctly propagates KeyboardInterrupt by testing manually with a sleep:

INFO:root:Creating BadReduce object
INFO:root:Pickling
INFO:root:Unpickling
INFO:root:Sleeping a while - send keyboard interrupt to test
  C-c C-cTraceback (most recent call last):
  File "/home/zk8ms03/python/cpickle_reduce_failure.py", line 49, in <module>
    main()
  File "/home/zk8ms03/python/cpickle_reduce_failure.py", line 42, in main
    pickler.loads(s1)
  File "/home/zk8ms03/python/cpickle_reduce_failure.py", line 28, in __init__
    time.sleep(5.0)
KeyboardInterrupt: (None, <class '__main__.BadReduce'>, (1123,))


I'm not sure how likely it is that anyone depends on the extra information that cPickle adds in these cases, so I'll leave it up to others to decide what's best.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28925>
_______________________________________


More information about the Python-bugs-list mailing list