[3.11] gh-106107: document correct error that's raised when a mutable default value for a field is detected (gh-106109) (gh-106116)

gh-106107: document correct error that's raised when a mutable default value for a field is detected (gh-106109)
(cherry picked from commit 512f299e55)

Co-authored-by: Roderich Schupp <roderich.schupp@gmail.com>
This commit is contained in:
Miss Islington (bot) 2023-06-26 11:12:40 -07:00 committed by GitHub
parent 307c59a0c1
commit 97cf0291f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -733,7 +733,7 @@ for ``x`` when creating a class instance will share the same copy
of ``x``. Because dataclasses just use normal Python class of ``x``. Because dataclasses just use normal Python class
creation they also share this behavior. There is no general way creation they also share this behavior. There is no general way
for Data Classes to detect this condition. Instead, the 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 detects an unhashable default parameter. The assumption is that if
a value is unhashable, it is mutable. This is a partial solution, a value is unhashable, it is mutable. This is a partial solution,
but it does protect against many common errors. but it does protect against many common errors.