Skip to content

Commit de28651

Browse files
authored
gh-123299: Some copyedits to What's New in 3.14 (#133622)
1 parent 4fd1095 commit de28651

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

Doc/whatsnew/3.14.rst

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ As another example, generating HTML attributes from data:
153153
.. code-block:: python
154154
155155
attributes = {"src": "shrubbery.jpg", "alt": "looks nice"}
156-
template = t"<img {attributes} />"
157-
assert html(template) == '<img src="shrubbery.jpg" alt="looks nice" class="looks-nice" />'
156+
template = t"<img {attributes}>"
157+
assert html(template) == '<img src="shrubbery.jpg" alt="looks nice" class="looks-nice">'
158158
159-
Unlike f-strings, the ``html`` function has access to template attributes
159+
Compared to using an f-string, the ``html`` function has access to template attributes
160160
containing the original information: static strings, interpolations, and values
161161
from the original scope. Unlike existing templating approaches, t-strings build
162162
from the well-known f-string syntax and rules. Template systems thus benefit
@@ -443,6 +443,9 @@ Python without deferred evaluation of annotations, reaches its end of life in 20
443443
In Python 3.14, the behavior of code using ``from __future__ import annotations``
444444
is unchanged.
445445

446+
.. seealso::
447+
:pep:`649`.
448+
446449

447450
Improved error messages
448451
-----------------------
@@ -584,8 +587,27 @@ Improved error messages
584587
^^^^^^
585588
SyntaxError: cannot use subscript as import target
586589
587-
.. seealso::
588-
:pep:`649`.
590+
* Improved error message when trying to add an instance of an unhashable type to
591+
a :class:`dict` or :class:`set`. (Contributed by CF Bolz-Tereick and Victor Stinner
592+
in :gh:`132828`.)
593+
594+
.. code-block:: pycon
595+
596+
>>> s = set()
597+
>>> s.add({'pages': 12, 'grade': 'A'})
598+
Traceback (most recent call last):
599+
File "<python-input-1>", line 1, in <module>
600+
s.add({'pages': 12, 'grade': 'A'})
601+
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
602+
TypeError: cannot use 'dict' as a set element (unhashable type: 'dict')
603+
>>> d = {}
604+
>>> l = [1, 2, 3]
605+
>>> d[l] = 12
606+
Traceback (most recent call last):
607+
File "<python-input-4>", line 1, in <module>
608+
d[l] = 12
609+
~^^^
610+
TypeError: cannot use 'list' as a dict key (unhashable type: 'list')
589611
590612
591613
.. _whatsnew314-pep741:

0 commit comments

Comments
 (0)