From ee4030ca6bcd6f0ff8ce6b4a12a985c27394ad82 Mon Sep 17 00:00:00 2001 From: tangyuan0821 Date: Tue, 19 Aug 2025 14:52:50 +0800 Subject: [PATCH 1/2] Doc: Improve dataclasses frozen parameter documentation --- Doc/library/dataclasses.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index 299c8aa399c25c..556ba8774c2e89 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -161,9 +161,11 @@ Module contents :class:`object`, this means it will fall back to id-based hashing). - *frozen*: If true (the default is ``False``), assigning to fields will - generate an exception. This emulates read-only frozen instances. If - :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class, then - :exc:`TypeError` is raised. See the discussion below. + generate an exception. This emulates read-only frozen instances. + See the :ref:`discussion ` below. + + If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class, + then :exc:`TypeError` is raised. - *match_args*: If true (the default is ``True``), the :attr:`~object.__match_args__` tuple will be created from the list of From 83d332b281ceeb93f2bd5c7a9137e6c057ccb457 Mon Sep 17 00:00:00 2001 From: tangyuan0821 Date: Wed, 20 Aug 2025 08:43:56 +0800 Subject: [PATCH 2/2] Update the description of the TypeError exception regarding freezing instances --- Doc/library/dataclasses.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index 556ba8774c2e89..2e4520c823bf3e 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -164,8 +164,8 @@ Module contents generate an exception. This emulates read-only frozen instances. See the :ref:`discussion ` below. - If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class, - then :exc:`TypeError` is raised. + If :meth:`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the class + and *frozen* is true, then :exc:`TypeError` is raised. - *match_args*: If true (the default is ``True``), the :attr:`~object.__match_args__` tuple will be created from the list of