This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author a.badger
Recipients a.badger
Date 2020-06-08.23:46:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1591659970.45.0.239988250333.issue40917@roundup.psfhosted.org>
In-reply-to
Content
I was trying to use multiprocessing (via a concurrent.futures.ProcessPoolExecutor) and encountered an error when pickling a custom Exception.  On closer examination I was able to create a simple test case that only involves pickle:


import pickle
class StrRegexError(Exception):
    def __init__(self, *, pattern):
        self.pattern = pattern

data = pickle.dumps(StrRegexError(pattern='test'))
instance = pickle.loads(data)


[pts/11@peru /srv/ansible]$ python3.8 ~/p.py
Traceback (most recent call last):
  File "/home/badger/p.py", line 7, in <module>
    instance = pickle.loads(data)
TypeError: __init__() missing 1 required keyword-only argument: 'pattern'

pickle can handle mandatory keyword args in other classes derived from object; it's only classes derived from Exception that have issues.
History
Date User Action Args
2020-06-08 23:46:10a.badgersetrecipients: + a.badger
2020-06-08 23:46:10a.badgersetmessageid: <1591659970.45.0.239988250333.issue40917@roundup.psfhosted.org>
2020-06-08 23:46:10a.badgerlinkissue40917 messages
2020-06-08 23:46:10a.badgercreate