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

ericvsmith webhook-mailer at python.org
Mon Jun 26 14:12:56 EDT 2023


https://github.com/python/cpython/commit/ea6a4b7523a356b3e3c9182ad34b23f91885a335
commit: ea6a4b7523a356b3e3c9182ad34b23f91885a335
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: ericvsmith <ericvsmith at users.noreply.github.com>
date: 2023-06-26T14:12:52-04:00
summary:

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

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 at gmail.com>

files:
M Doc/library/dataclasses.rst

diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst
index a5b201499210..535a60ccca8d 100644
--- a/Doc/library/dataclasses.rst
+++ b/Doc/library/dataclasses.rst
@@ -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.



More information about the Python-checkins mailing list