aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandrei kulakov <andrei.avk@gmail.com>2021-09-29 07:44:43 -0400
committerGitHub <noreply@github.com>2021-09-29 12:44:43 +0100
commitf76889a88720b56c8174f26a20a8e676a460c7a6 (patch)
tree551f3e3fcbd100789249a94f32519becba309a3a
parentbpo-45291: Explicitly set --libdir=lib when configure OpenSSL (GH-28566) (diff)
downloadcpython-f76889a88720b56c8174f26a20a8e676a460c7a6.tar.gz
cpython-f76889a88720b56c8174f26a20a8e676a460c7a6.tar.bz2
cpython-f76889a88720b56c8174f26a20a8e676a460c7a6.zip
Fix doctest doc examples for syntax errors (GH-28486)
* fix doctest doc examples for syntax errors * updated examples to use TypeErrors * fixed first sentence * unneeded comma
-rw-r--r--Doc/library/doctest.rst21
1 files changed, 10 insertions, 11 deletions
diff --git a/Doc/library/doctest.rst b/Doc/library/doctest.rst
index a77322f83ac..0bbb640bea2 100644
--- a/Doc/library/doctest.rst
+++ b/Doc/library/doctest.rst
@@ -485,25 +485,24 @@ Some details you should read once, but won't need to remember:
.. index:: single: ^ (caret); marker
-* For some :exc:`SyntaxError`\ s, Python displays the character position of the
- syntax error, using a ``^`` marker::
+* For some exceptions, Python displays the position of the error using ``^``
+ markers and tildes::
- >>> 1 1
+ >>> 1 + None
File "<stdin>", line 1
- 1 1
- ^
- SyntaxError: invalid syntax
+ 1 + None
+ ~~^~~~~~
+ TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
Since the lines showing the position of the error come before the exception type
and detail, they are not checked by doctest. For example, the following test
would pass, even though it puts the ``^`` marker in the wrong location::
- >>> 1 1
- Traceback (most recent call last):
+ >>> 1 + None
File "<stdin>", line 1
- 1 1
- ^
- SyntaxError: invalid syntax
+ 1 + None
+ ^~~~~~~~
+ TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
.. _option-flags-and-directives: