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.

classification
Title: Cannot pickle frozen dataclasses with slots
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.smith Nosy List: eric.smith
Priority: deferred blocker Keywords: patch

Created on 2021-05-01 16:03 by eric.smith, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 25786 merged eric.smith, 2021-05-01 16:58
Messages (1)
msg392603 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-05-01 16:03
Originally reported in https://github.com/ericvsmith/dataclasses/issues/154

import pickle
from dataclasses import dataclass

@dataclass(frozen=True, slots=True)
class ExampleDataclass:
    foo: str
    bar: int



assert ExampleDataclass.__slots__ == ("foo", "bar")

assert pickle.loads(
    pickle.dumps(ExampleDataclass("a", 1))
) == ExampleDataclass("a", 1)

  File "<string>", line 4, in __setattr__
dataclasses.FrozenInstanceError: cannot assign to field 'foo'

I'll get a PR ready, likely based on ariebovenberg's solution in the above mentioned issue.
History
Date User Action Args
2022-04-11 14:59:45adminsetgithub: 88165
2021-05-01 21:09:25eric.smithsettype: behavior
2021-05-01 17:30:03eric.smithsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-05-01 16:58:42eric.smithsetkeywords: + patch
stage: patch review
pull_requests: + pull_request24477
2021-05-01 16:03:38eric.smithcreate