mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
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
This commit is contained in:
parent
bc4cde4033
commit
f76889a887
1 changed files with 10 additions and 11 deletions
|
@ -485,25 +485,24 @@ Some details you should read once, but won't need to remember:
|
||||||
|
|
||||||
.. index:: single: ^ (caret); marker
|
.. index:: single: ^ (caret); marker
|
||||||
|
|
||||||
* For some :exc:`SyntaxError`\ s, Python displays the character position of the
|
* For some exceptions, Python displays the position of the error using ``^``
|
||||||
syntax error, using a ``^`` marker::
|
markers and tildes::
|
||||||
|
|
||||||
>>> 1 1
|
>>> 1 + None
|
||||||
File "<stdin>", line 1
|
File "<stdin>", line 1
|
||||||
1 1
|
1 + None
|
||||||
^
|
~~^~~~~~
|
||||||
SyntaxError: invalid syntax
|
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
|
||||||
|
|
||||||
Since the lines showing the position of the error come before the exception type
|
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
|
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::
|
would pass, even though it puts the ``^`` marker in the wrong location::
|
||||||
|
|
||||||
>>> 1 1
|
>>> 1 + None
|
||||||
Traceback (most recent call last):
|
|
||||||
File "<stdin>", line 1
|
File "<stdin>", line 1
|
||||||
1 1
|
1 + None
|
||||||
^
|
^~~~~~~~
|
||||||
SyntaxError: invalid syntax
|
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
|
||||||
|
|
||||||
|
|
||||||
.. _option-flags-and-directives:
|
.. _option-flags-and-directives:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue