]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-106107: document correct error that's raised when a mutable default value...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 26 Jun 2023 18:12:40 +0000 (11:12 -0700)
committerGitHub <noreply@github.com>
Mon, 26 Jun 2023 18:12:40 +0000 (14:12 -0400)
gh-106107: document correct error that's raised when a mutable default value for a field is detected (gh-106109)
(cherry picked from commit 512f299e557f4ab60768d36cee9968bd92116367)

Co-authored-by: Roderich Schupp <roderich.schupp@gmail.com>
Doc/library/dataclasses.rst

index 58bf96bf4f06a1533ba28aea5683ad8663d3c5f0..aa71e5e735f2c5f740412a8d9ba71fb2e0471301 100644 (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
 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.