From 2261c4d22f6520c85617e4ccfa1243edb0bbf7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric?= Date: Wed, 7 May 2025 17:31:31 -0400 Subject: [PATCH 1/5] minor copyedit to HTML example --- Doc/whatsnew/3.14.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 894f011ec86a30..236ec732acc6f0 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -153,8 +153,8 @@ As another example, generating HTML attributes from data: .. code-block:: python attributes = {"src": "shrubbery.jpg", "alt": "looks nice"} - template = t"" - assert html(template) == 'looks nice' + template = t"" + assert html(template) == 'looks nice' Unlike f-strings, the ``html`` function has access to template attributes containing the original information: static strings, interpolations, and values From 0178dfbaef322c01623cc799b3252a5e71935c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric?= Date: Wed, 7 May 2025 17:58:06 -0400 Subject: [PATCH 2/5] avoid grammar issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The referent is broken between the two parts on each side of the comma. Also, «unlike» was used twice in this paragraph, but in different directions (t-strings are better than f-strings for structured processing / t-strings are nicer than other templates because similar to f-strings!) Rewrite sligtly to avoid these two jarring effects --- Doc/whatsnew/3.14.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 236ec732acc6f0..9133a0f967ab7f 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -156,7 +156,7 @@ As another example, generating HTML attributes from data: template = t"" assert html(template) == 'looks nice' -Unlike f-strings, the ``html`` function has access to template attributes +Compared to using an f-string, the ``html`` function has access to template attributes containing the original information: static strings, interpolations, and values from the original scope. Unlike existing templating approaches, t-strings build from the well-known f-string syntax and rules. Template systems thus benefit From 62a053960b705a0f36f72c1da926e826ce3d1d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric?= Date: Wed, 7 May 2025 17:59:56 -0400 Subject: [PATCH 3/5] fix orphaned seealso block --- Doc/whatsnew/3.14.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index 9133a0f967ab7f..b953f1fc04abb4 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -443,6 +443,9 @@ Python without deferred evaluation of annotations, reaches its end of life in 20 In Python 3.14, the behavior of code using ``from __future__ import annotations`` is unchanged. +.. seealso:: + :pep:`649`. + Improved error messages ----------------------- @@ -584,8 +587,6 @@ Improved error messages ^^^^^^ SyntaxError: cannot use subscript as import target -.. seealso:: - :pep:`649`. .. _whatsnew314-pep741: From e40c42048388f7e2f66f0c93816b270b68428fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric?= Date: Wed, 7 May 2025 18:04:14 -0400 Subject: [PATCH 4/5] add improved unhashable type error messages to whatsnew --- Doc/whatsnew/3.14.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index b953f1fc04abb4..e5468a2229fe42 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -587,6 +587,24 @@ Improved error messages ^^^^^^ SyntaxError: cannot use subscript as import target +* Improved error message when trying to add an instance of an unhashable type + to a :class:`dict` or :class:`set`: + + (Contributed by Victor Stinner in :gh:`426449d`.) + + .. code-block:: pycon + + >>> s = set() + >>> s.add({'pages': 12, 'grade': 'A'}) + Traceback (most recent call last): + File "", line 1, in + TypeError: Cannot use 'dict' as a set element (unhashable type). + >>> d = {} + >>> l = [1, 2, 3] + >>> d[l] = 12 + Traceback (most recent call last): + File "", line 1, in + TypeError: Cannot use 'list' as a dict key (unhashable type). .. _whatsnew314-pep741: From dfa24b8f292283f2c84812ffd49df282dc0f8924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric?= Date: Thu, 8 May 2025 16:23:24 -0400 Subject: [PATCH 5/5] edits Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Doc/whatsnew/3.14.rst | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Doc/whatsnew/3.14.rst b/Doc/whatsnew/3.14.rst index e5468a2229fe42..9265024378cc6c 100644 --- a/Doc/whatsnew/3.14.rst +++ b/Doc/whatsnew/3.14.rst @@ -587,24 +587,27 @@ Improved error messages ^^^^^^ SyntaxError: cannot use subscript as import target -* Improved error message when trying to add an instance of an unhashable type - to a :class:`dict` or :class:`set`: - - (Contributed by Victor Stinner in :gh:`426449d`.) +* Improved error message when trying to add an instance of an unhashable type to + a :class:`dict` or :class:`set`. (Contributed by CF Bolz-Tereick and Victor Stinner + in :gh:`132828`.) .. code-block:: pycon >>> s = set() >>> s.add({'pages': 12, 'grade': 'A'}) Traceback (most recent call last): - File "", line 1, in - TypeError: Cannot use 'dict' as a set element (unhashable type). + File "", line 1, in + s.add({'pages': 12, 'grade': 'A'}) + ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + TypeError: cannot use 'dict' as a set element (unhashable type: 'dict') >>> d = {} >>> l = [1, 2, 3] >>> d[l] = 12 Traceback (most recent call last): - File "", line 1, in - TypeError: Cannot use 'list' as a dict key (unhashable type). + File "", line 1, in + d[l] = 12 + ~^^^ + TypeError: cannot use 'list' as a dict key (unhashable type: 'list') .. _whatsnew314-pep741: