New submission from Brian Quinlan <[email protected]>:
$ ./python.exe nopickle.py
TypeError: __init__() missing 1 required positional argument: 'num'
The issue is that the arguments passed to Exception.__init__ (via `super()`)
are collected into `args` and then serialized by pickle e.g.
>>> PickleBreaker(5).args
()
>>> PickleBreaker(5).__reduce_ex__(3)
(<class '__main__.PoolBreaker'>, (), {'num': 5})
>>> # The 1st index is the `args` tuple
Then, during load, the `args` tuple is used to initialize the Exception i.e.
PickleBreaker(), which results in the `TypeError`
See https://github.com/python/cpython/blob/master/Modules/_pickle.c#L6769
----------
components: Library (Lib)
files: nopickle.py
messages: 345647
nosy: bquinlan
priority: normal
severity: normal
status: open
title: picke cannot dump exceptions subclasses with different super() args
versions: Python 3.7, Python 3.8, Python 3.9
Added file: https://bugs.python.org/file48420/nopickle.py
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37287>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com