mirror of
https://github.com/python/cpython
synced 2024-09-19 21:21:40 +00:00
gh-106107: document correct error that's raised when a mutable default value for a field is detected (gh-106109)
This commit is contained in:
parent
219effa876
commit
512f299e55
|
@ -738,7 +738,7 @@ for ``x`` when creating a class instance will share the same copy
|
|||
of ``x``. Because dataclasses just use normal Python class
|
||||
creation they also share this behavior. There is no general way
|
||||
for Data Classes to detect this condition. Instead, the
|
||||
:func:`dataclass` decorator will raise a :exc:`TypeError` if it
|
||||
:func:`dataclass` decorator will raise a :exc:`ValueError` if it
|
||||
detects an unhashable default parameter. The assumption is that if
|
||||
a value is unhashable, it is mutable. This is a partial solution,
|
||||
but it does protect against many common errors.
|
||||
|
|
Loading…
Reference in a new issue