Skip to content

Commit 57b8fc8

Browse files
committed
Use doctest format with traceback in What's New entry
1 parent 579d037 commit 57b8fc8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Doc/whatsnew/3.15.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,20 +425,26 @@ Improved error messages
425425
method names from other languages (JavaScript, Java, Ruby, C#) and suggests
426426
the Python equivalent:
427427

428-
.. code-block:: pycon
428+
.. doctest::
429429

430-
>>> [1, 2, 3].push(4)
430+
>>> [1, 2, 3].push(4) # doctest: +ELLIPSIS
431+
Traceback (most recent call last):
432+
...
431433
AttributeError: 'list' object has no attribute 'push'. Did you mean '.append'?
432434

433-
>>> 'hello'.toUpperCase()
435+
>>> 'hello'.toUpperCase() # doctest: +ELLIPSIS
436+
Traceback (most recent call last):
437+
...
434438
AttributeError: 'str' object has no attribute 'toUpperCase'. Did you mean '.upper'?
435439

436440
When the Python equivalent is a language construct rather than a method,
437441
the hint describes the construct directly:
438442

439-
.. code-block:: pycon
443+
.. doctest::
440444

441-
>>> {}.put("a", 1)
445+
>>> {}.put("a", 1) # doctest: +ELLIPSIS
446+
Traceback (most recent call last):
447+
...
442448
AttributeError: 'dict' object has no attribute 'put'. Use dict[key] = value for item assignment
443449

444450
(Contributed by Matt Van Horn in :gh:`146406`.)

0 commit comments

Comments
 (0)