From d2ba756912d7bdc9e28a898f82765715737f80d2 Mon Sep 17 00:00:00 2001 From: decorator-factory <42166884+decorator-factory@users.noreply.github.com> Date: Sun, 14 Dec 2025 15:22:33 +0300 Subject: [PATCH] [3.13] gh-142411: Change documentation to reflect the new docstring adjustments in 3.13 (GH-142413) (#142690) --- Doc/library/functions.rst | 4 ++-- Doc/tutorial/controlflow.rst | 23 ++++++++++------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index d9ec50acf220..e08d5d2a9954 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -334,8 +334,8 @@ are always available. They are listed here in alphabetical order. ``__debug__`` is true), ``1`` (asserts are removed, ``__debug__`` is false) or ``2`` (docstrings are removed too). - This function raises :exc:`SyntaxError` if the compiled source is invalid, - and :exc:`ValueError` if the source contains null bytes. + This function raises :exc:`SyntaxError` or :exc:`ValueError` if the compiled + source is invalid. If you want to parse Python code into its AST representation, see :func:`ast.parse`. diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index 2e7e188806f6..da70a718fc24 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -1038,31 +1038,28 @@ blank, visually separating the summary from the rest of the description. The following lines should be one or more paragraphs describing the object's calling conventions, its side effects, etc. -The Python parser does not strip indentation from multi-line string literals in -Python, so tools that process documentation have to strip indentation if -desired. This is done using the following convention. The first non-blank line -*after* the first line of the string determines the amount of indentation for -the entire documentation string. (We can't use the first line since it is -generally adjacent to the string's opening quotes so its indentation is not -apparent in the string literal.) Whitespace "equivalent" to this indentation is -then stripped from the start of all lines of the string. Lines that are -indented less should not occur, but if they occur all their leading whitespace -should be stripped. Equivalence of whitespace should be tested after expansion -of tabs (to 8 spaces, normally). +The Python parser strips indentation from multi-line string literals when they +serve as module, class, or function docstrings. Here is an example of a multi-line docstring:: >>> def my_function(): ... """Do nothing, but document it. ... - ... No, really, it doesn't do anything. + ... No, really, it doesn't do anything: + ... + ... >>> my_function() + ... >>> ... """ ... pass ... >>> print(my_function.__doc__) Do nothing, but document it. - No, really, it doesn't do anything. + No, really, it doesn't do anything: + + >>> my_function() + >>> .. _tut-annotations: -- 2.47.3