[issue43176] Dataclasses derived from empty frozen bases skip immutability checks
Ulrich Petri
report at bugs.python.org
Thu May 6 17:34:30 EDT 2021
Ulrich Petri <python at ulo.pe> added the comment:
@eric.smith Sure, here you go:
dataclass_empty.py:
```
from dataclasses import dataclass
@dataclass
class A:
pass
@dataclass(frozen=True)
class B(A):
x: int
print("42")
```
Running this on < 3.8.10:
```
$ ~/.pythonz/pythons/CPython-3.8.1/bin/python3.8 --version
Python 3.8.1
$ ~/.pythonz/pythons/CPython-3.8.1/bin/python3.8 dataclass_empty.py
42
```
And on 3.8.10:
```
$ /usr/local/opt/python at 3.8/bin/python3 --version
Python 3.8.10
$ /usr/local/opt/python at 3.8/bin/python3 dataclass_empty.py
Traceback (most recent call last):
File "dataclass_empty.py", line 10, in <module>
class B(A):
File "/usr/local/Cellar/python at 3.8/3.8.10/Frameworks/Python.framework/Versions/3.8/lib/python3.8/dataclasses.py", line 1011, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
File "/usr/local/Cellar/python at 3.8/3.8.10/Frameworks/Python.framework/Versions/3.8/lib/python3.8/dataclasses.py", line 896, in _process_class
raise TypeError('cannot inherit frozen dataclass from a '
TypeError: cannot inherit frozen dataclass from a non-frozen one
```
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43176>
_______________________________________
More information about the Python-bugs-list
mailing list