New submission from Eric V. Smith <e...@trueblade.com>:

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.

----------
assignee: eric.smith
components: Library (Lib)
messages: 392603
nosy: eric.smith
priority: deferred blocker
severity: normal
status: open
title: Cannot pickle frozen dataclasses with slots
versions: Python 3.10

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43999>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to