[New-bugs-announce] [issue43999] Cannot pickle frozen dataclasses with slots
Eric V. Smith
report at bugs.python.org
Sat May 1 12:03:38 EDT 2021
New submission from Eric V. Smith <eric at 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 <report at bugs.python.org>
<https://bugs.python.org/issue43999>
_______________________________________
More information about the New-bugs-announce
mailing list