https://github.com/python/cpython/commit/848e71788019654f3e0f9998be9267779f9b8e34 commit: 848e71788019654f3e0f9998be9267779f9b8e34 branch: 3.15 author: Miss Islington (bot) <[email protected]> committer: methane <[email protected]> date: 2026-10-31T05:50:08Z summary:
Docs: correct built-in exception, function, and dictionary descriptions (GH-160979) (cherry picked from commit 3fb88e94db547e9dbed97de68da87bcf9335a53a) Co-authored-by: Inada Naoki <[email protected]> files: M Doc/builtins/exceptions.rst M Doc/builtins/functions.rst M Doc/builtins/stdtypes.rst M Lib/test/exception_hierarchy.txt diff --git a/Doc/builtins/exceptions.rst b/Doc/builtins/exceptions.rst index 3775d5ac81a2736..cd1e844a5b50fed 100644 --- a/Doc/builtins/exceptions.rst +++ b/Doc/builtins/exceptions.rst @@ -394,10 +394,9 @@ The following exceptions are the exceptions that are usually raised. .. attribute:: strerror - The corresponding error message, as provided by - the operating system. It is formatted by the C - functions :c:func:`!perror` under POSIX, and :c:func:`!FormatMessage` - under Windows. + The corresponding error message, as provided by the operating system. + Under POSIX, it is obtained using the C functions :c:func:`!strerror` + or :c:func:`!strerror_r`; under Windows, :c:func:`!FormatMessage` is used. .. attribute:: filename filename2 @@ -565,11 +564,6 @@ The following exceptions are the exceptions that are usually raised. The column in the end line where the error occurred finishes. This is 1-indexed: the first character in the line has an ``offset`` of 1. - For errors in f-string fields, the message is prefixed by "f-string: " - and the offsets are offsets in a text constructed from the replacement - expression. For example, compiling f'Bad {a b} field' results in this - args attribute: ('f-string: ...', ('', 1, 2, '(a b)\n', 1, 5)). - .. versionchanged:: 3.10 Added the :attr:`end_lineno` and :attr:`end_offset` attributes. diff --git a/Doc/builtins/functions.rst b/Doc/builtins/functions.rst index 4a725802f80d90f..ea5560c5ebfa042 100644 --- a/Doc/builtins/functions.rst +++ b/Doc/builtins/functions.rst @@ -732,7 +732,7 @@ are always available. They are listed here in alphabetical order. still access all builtins. The *closure* argument specifies a closure--a tuple of cellvars. - It's only valid when the *object* is a code object containing + It's only valid when *source* is a code object containing :term:`free (closure) variables <closure variable>`. The length of the tuple must exactly match the length of the code object's :attr:`~codeobject.co_freevars` attribute. @@ -2101,10 +2101,10 @@ are always available. They are listed here in alphabetical order. When called directly within an ordinary method of a class, both arguments may be omitted ("zero-argument :func:`!super`"). In this case, *type* will be the - enclosing class, and *obj* will be the first argument of the immediately - enclosing function (typically ``self``). (This means that zero-argument + enclosing class, and *object_or_type* will be the first argument of the + immediately enclosing function (typically ``self``). Zero-argument :func:`!super` will not work as expected within nested functions, including - generator expressions, which implicitly create nested functions.) + generator expressions, which implicitly create nested functions. There are two typical use cases for *super*. In a class hierarchy with single inheritance, *super* can be used to refer to parent classes without @@ -2363,10 +2363,9 @@ are always available. They are listed here in alphabetical order. determine the package context of the :keyword:`import` statement. *level* specifies whether to use absolute or relative imports. ``0`` (the - default) means only perform absolute imports. Positive values for - *level* indicate the number of parent directories to search relative to the - directory of the module calling :func:`__import__` (see :pep:`328` for the - details). + default) means only perform absolute imports. For relative imports, + ``1`` refers to the current package, ``2`` to its parent package, and so on + (see :pep:`328` for details). When the *name* variable is of the form ``package.module``, normally, the top-level package (the name up till the first dot) is returned, *not* the diff --git a/Doc/builtins/stdtypes.rst b/Doc/builtins/stdtypes.rst index 9e2841a4a4f65c4..3652ccf8b28d7ba 100644 --- a/Doc/builtins/stdtypes.rst +++ b/Doc/builtins/stdtypes.rst @@ -5644,7 +5644,7 @@ can be used interchangeably to index the same dictionary entry. * Use a comma-separated list of ``key: value`` pairs within braces: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}`` - * Use a dict comprehension: ``{}``, ``{x: x ** 2 for x in range(10)}`` + * Use a dict comprehension: ``{x: x ** 2 for x in range(10)}`` * Use the type constructor: ``dict()``, ``dict([('foo', 100), ('bar', 200)])``, ``dict(foo=100, bar=200)`` @@ -5855,9 +5855,8 @@ can be used interchangeably to index the same dictionary entry. Return a new view of the dictionary's values. See the :ref:`documentation of view objects <dict-views>`. - An equality comparison between one ``dict.values()`` view and another - will always return ``False``. This also applies when comparing - ``dict.values()`` to itself:: + An equality comparison between two distinct ``dict.values()`` views + will always return ``False``, even for views of the same dictionary:: >>> d = {'a': 1} >>> d.values() == d.values() diff --git a/Lib/test/exception_hierarchy.txt b/Lib/test/exception_hierarchy.txt index 98a5e950602eafc..6e9b1912ab67801 100644 --- a/Lib/test/exception_hierarchy.txt +++ b/Lib/test/exception_hierarchy.txt @@ -14,7 +14,7 @@ BaseException ├── EOFError ├── ExceptionGroup [BaseExceptionGroup] ├── ImportError - │ └── ImportCycleError + │ ├── ImportCycleError │ └── ModuleNotFoundError ├── LookupError │ ├── IndexError _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
