Skip to content

Exception subclass can't be unpickled #98873

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

Closed
youtux opened this issue Oct 30, 2022 · 1 comment
Closed

Exception subclass can't be unpickled #98873

youtux opened this issue Oct 30, 2022 · 1 comment
Labels
type-bug An unexpected behavior, bug, or error

Comments

@youtux
Copy link

youtux commented Oct 30, 2022

Bug report

This exception subclass can't be unpickled, but I think it should be able to be unpickled fine:

import pickle

class MyException(Exception):
    def __init__(self, msg, another_arg):
        super().__init__(msg)
        self.another_arg = another_arg

m = MyException("hello", 12)

pickle.loads(pickle.dumps(m))  # error

# Traceback (most recent call last):
#   File "<stdin>", line 1, in <module>
# TypeError: MyException.__init__() missing 1 required positional argument: 'another_arg'

Discovered in celery/celery#6990

Your environment

  • CPython versions tested on: python 3.10.8
  • Operating system and architecture: MacOS 12.6, Intel
@youtux youtux added the type-bug An unexpected behavior, bug, or error label Oct 30, 2022
@hauntsaninja
Copy link
Contributor

Duplicate of #76877

@hauntsaninja hauntsaninja marked this as a duplicate of #76877 Oct 30, 2022
@youtux youtux closed this as completed Oct 30, 2022
@youtux youtux reopened this Oct 30, 2022
@youtux youtux closed this as not planned Won't fix, can't repro, duplicate, stale Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants