[New-bugs-announce] [issue43176] Dataclasses derived from empty frozen bases skip immutability checks
Iurii Kemaev
report at bugs.python.org
Tue Feb 9 02:12:39 EST 2021
New submission from Iurii Kemaev <y.kemaev at gmail.com>:
Dataclasses derived from empty frozen bases skip immutability checks.
Repro snippet:
```
import dataclasses
@dataclasses.dataclass(frozen=True)
class Base:
pass
@dataclasses.dataclass
class Derived(Base):
a: int
d = Derived(2)
# OK
```
Usecase: sometimes developers define an empty frozen base dataclass with detailed docs and require other dataclasses to inherit from it as a code contract to avoid accidental in-place modifications.
This bug makes this strategy ineffective.
Affects all versions of Python that support dataclasses (including the backport for py3.6).
----------
components: Library (Lib)
messages: 386695
nosy: hbq1
priority: normal
pull_requests: 23278
severity: normal
status: open
title: Dataclasses derived from empty frozen bases skip immutability checks
type: behavior
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43176>
_______________________________________
More information about the New-bugs-announce
mailing list