Skip to content

Commit bb4b246

Browse files
methanemiss-islington
authored andcommitted
Docs: correct built-in exception, function, and dictionary descriptions (GH-160979)
(cherry picked from commit 3fb88e9) Co-authored-by: Inada Naoki <songofacandy@gmail.com>
1 parent fe305f8 commit bb4b246

4 files changed

Lines changed: 14 additions & 22 deletions

File tree

‎Doc/builtins/exceptions.rst‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,9 @@ The following exceptions are the exceptions that are usually raised.
394394

395395
.. attribute:: strerror
396396

397-
The corresponding error message, as provided by
398-
the operating system. It is formatted by the C
399-
functions :c:func:`!perror` under POSIX, and :c:func:`!FormatMessage`
400-
under Windows.
397+
The corresponding error message, as provided by the operating system.
398+
Under POSIX, it is obtained using the C functions :c:func:`!strerror`
399+
or :c:func:`!strerror_r`; under Windows, :c:func:`!FormatMessage` is used.
401400

402401
.. attribute:: filename
403402
filename2
@@ -565,11 +564,6 @@ The following exceptions are the exceptions that are usually raised.
565564
The column in the end line where the error occurred finishes. This is
566565
1-indexed: the first character in the line has an ``offset`` of 1.
567566

568-
For errors in f-string fields, the message is prefixed by "f-string: "
569-
and the offsets are offsets in a text constructed from the replacement
570-
expression. For example, compiling f'Bad {a b} field' results in this
571-
args attribute: ('f-string: ...', ('', 1, 2, '(a b)\n', 1, 5)).
572-
573567
.. versionchanged:: 3.10
574568
Added the :attr:`end_lineno` and :attr:`end_offset` attributes.
575569

‎Doc/builtins/functions.rst‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ are always available. They are listed here in alphabetical order.
732732
still access all builtins.
733733

734734
The *closure* argument specifies a closure--a tuple of cellvars.
735-
It's only valid when the *object* is a code object containing
735+
It's only valid when *source* is a code object containing
736736
:term:`free (closure) variables <closure variable>`.
737737
The length of the tuple must exactly match the length of the code object's
738738
:attr:`~codeobject.co_freevars` attribute.
@@ -2101,10 +2101,10 @@ are always available. They are listed here in alphabetical order.
21012101

21022102
When called directly within an ordinary method of a class, both arguments may
21032103
be omitted ("zero-argument :func:`!super`"). In this case, *type* will be the
2104-
enclosing class, and *obj* will be the first argument of the immediately
2105-
enclosing function (typically ``self``). (This means that zero-argument
2104+
enclosing class, and *object_or_type* will be the first argument of the
2105+
immediately enclosing function (typically ``self``). Zero-argument
21062106
:func:`!super` will not work as expected within nested functions, including
2107-
generator expressions, which implicitly create nested functions.)
2107+
generator expressions, which implicitly create nested functions.
21082108

21092109
There are two typical use cases for *super*. In a class hierarchy with
21102110
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.
23632363
determine the package context of the :keyword:`import` statement.
23642364

23652365
*level* specifies whether to use absolute or relative imports. ``0`` (the
2366-
default) means only perform absolute imports. Positive values for
2367-
*level* indicate the number of parent directories to search relative to the
2368-
directory of the module calling :func:`__import__` (see :pep:`328` for the
2369-
details).
2366+
default) means only perform absolute imports. For relative imports,
2367+
``1`` refers to the current package, ``2`` to its parent package, and so on
2368+
(see :pep:`328` for details).
23702369

23712370
When the *name* variable is of the form ``package.module``, normally, the
23722371
top-level package (the name up till the first dot) is returned, *not* the

‎Doc/builtins/stdtypes.rst‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5644,7 +5644,7 @@ can be used interchangeably to index the same dictionary entry.
56445644

56455645
* Use a comma-separated list of ``key: value`` pairs within braces:
56465646
``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}``
5647-
* Use a dict comprehension: ``{}``, ``{x: x ** 2 for x in range(10)}``
5647+
* Use a dict comprehension: ``{x: x ** 2 for x in range(10)}``
56485648
* Use the type constructor: ``dict()``,
56495649
``dict([('foo', 100), ('bar', 200)])``, ``dict(foo=100, bar=200)``
56505650

@@ -5855,9 +5855,8 @@ can be used interchangeably to index the same dictionary entry.
58555855
Return a new view of the dictionary's values. See the
58565856
:ref:`documentation of view objects <dict-views>`.
58575857

5858-
An equality comparison between one ``dict.values()`` view and another
5859-
will always return ``False``. This also applies when comparing
5860-
``dict.values()`` to itself::
5858+
An equality comparison between two distinct ``dict.values()`` views
5859+
will always return ``False``, even for views of the same dictionary::
58615860

58625861
>>> d = {'a': 1}
58635862
>>> d.values() == d.values()

‎Lib/test/exception_hierarchy.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ BaseException
1414
├── EOFError
1515
├── ExceptionGroup [BaseExceptionGroup]
1616
├── ImportError
17-
│ └── ImportCycleError
17+
│ ├── ImportCycleError
1818
│ └── ModuleNotFoundError
1919
├── LookupError
2020
│ ├── IndexError

0 commit comments

Comments
 (0)