Skip to content

Commit d2ba756

Browse files
[3.13] gh-142411: Change documentation to reflect the new docstring adjustments in 3.13 (GH-142413) (#142690)
1 parent d94a181 commit d2ba756

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

Doc/library/functions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ are always available. They are listed here in alphabetical order.
334334
``__debug__`` is true), ``1`` (asserts are removed, ``__debug__`` is false)
335335
or ``2`` (docstrings are removed too).
336336

337-
This function raises :exc:`SyntaxError` if the compiled source is invalid,
338-
and :exc:`ValueError` if the source contains null bytes.
337+
This function raises :exc:`SyntaxError` or :exc:`ValueError` if the compiled
338+
source is invalid.
339339

340340
If you want to parse Python code into its AST representation, see
341341
:func:`ast.parse`.

Doc/tutorial/controlflow.rst

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,31 +1038,28 @@ blank, visually separating the summary from the rest of the description. The
10381038
following lines should be one or more paragraphs describing the object's calling
10391039
conventions, its side effects, etc.
10401040

1041-
The Python parser does not strip indentation from multi-line string literals in
1042-
Python, so tools that process documentation have to strip indentation if
1043-
desired. This is done using the following convention. The first non-blank line
1044-
*after* the first line of the string determines the amount of indentation for
1045-
the entire documentation string. (We can't use the first line since it is
1046-
generally adjacent to the string's opening quotes so its indentation is not
1047-
apparent in the string literal.) Whitespace "equivalent" to this indentation is
1048-
then stripped from the start of all lines of the string. Lines that are
1049-
indented less should not occur, but if they occur all their leading whitespace
1050-
should be stripped. Equivalence of whitespace should be tested after expansion
1051-
of tabs (to 8 spaces, normally).
1041+
The Python parser strips indentation from multi-line string literals when they
1042+
serve as module, class, or function docstrings.
10521043

10531044
Here is an example of a multi-line docstring::
10541045

10551046
>>> def my_function():
10561047
... """Do nothing, but document it.
10571048
...
1058-
... No, really, it doesn't do anything.
1049+
... No, really, it doesn't do anything:
1050+
...
1051+
... >>> my_function()
1052+
... >>>
10591053
... """
10601054
... pass
10611055
...
10621056
>>> print(my_function.__doc__)
10631057
Do nothing, but document it.
10641058

1065-
No, really, it doesn't do anything.
1059+
No, really, it doesn't do anything:
1060+
1061+
>>> my_function()
1062+
>>>
10661063

10671064

10681065
.. _tut-annotations:

0 commit comments

Comments
 (0)