Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pickle exceptions with mandatory keyword args will traceback #85094

Closed
abadger mannequin opened this issue Jun 8, 2020 · 3 comments
Closed

pickle exceptions with mandatory keyword args will traceback #85094

abadger mannequin opened this issue Jun 8, 2020 · 3 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir

Comments

@abadger
Copy link
Mannequin

abadger mannequin commented Jun 8, 2020

BPO 40917
Nosy @abadger, @remilapeyre

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2020-06-12.02:00:02.122>
created_at = <Date 2020-06-08.23:46:10.416>
labels = ['3.8', '3.7', 'library', '3.9', '3.10']
title = 'pickle exceptions with mandatory keyword args will traceback'
updated_at = <Date 2020-06-12.02:00:02.120>
user = 'https://github.com/abadger'

bugs.python.org fields:

activity = <Date 2020-06-12.02:00:02.120>
actor = 'a.badger'
assignee = 'none'
closed = True
closed_date = <Date 2020-06-12.02:00:02.122>
closer = 'a.badger'
components = ['Library (Lib)']
creation = <Date 2020-06-08.23:46:10.416>
creator = 'a.badger'
dependencies = []
files = []
hgrepos = []
issue_num = 40917
keywords = []
message_count = 3.0
messages = ['371057', '371075', '371328']
nosy_count = 2.0
nosy_names = ['a.badger', 'remi.lapeyre']
pr_nums = []
priority = 'normal'
resolution = 'duplicate'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue40917'
versions = ['Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']

@abadger
Copy link
Mannequin Author

abadger mannequin commented Jun 8, 2020

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.

@abadger abadger mannequin added 3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir labels Jun 8, 2020
@abadger abadger mannequin changed the title pickling exceptions with mandatory keyword args will traceback pickle exceptions with mandatory keyword args will traceback Jun 9, 2020
@abadger abadger mannequin changed the title pickling exceptions with mandatory keyword args will traceback pickle exceptions with mandatory keyword args will traceback Jun 9, 2020
@remilapeyre
Copy link
Mannequin

remilapeyre mannequin commented Jun 9, 2020

This is a duplicate of bpo-27015.

@remilapeyre remilapeyre mannequin added 3.9 only security fixes 3.10 only security fixes labels Jun 9, 2020
@abadger
Copy link
Mannequin Author

abadger mannequin commented Jun 12, 2020

Thanks! I confirm that your PR #11580 for https://bugs.python.org/issue27015 fixes this problem.

Closing this one.

@abadger abadger mannequin closed this as completed Jun 12, 2020
@abadger abadger mannequin closed this as completed Jun 12, 2020
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

0 participants