Skip to content

Commit 3fb88e9

Browse files
authored
Docs: correct built-in exception, function, and dictionary descriptions (#160979)
1 parent 4a9b981 commit 3fb88e9

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
@@ -396,10 +396,9 @@ The following exceptions are the exceptions that are usually raised.
396396

397397
.. attribute:: strerror
398398

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

404403
.. attribute:: filename
405404
filename2
@@ -567,11 +566,6 @@ The following exceptions are the exceptions that are usually raised.
567566
The column in the end line where the error occurred finishes. This is
568567
1-indexed: the first character in the line has an ``offset`` of 1.
569568

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

‎Doc/builtins/functions.rst‎

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

774774
The *closure* argument specifies a closure--a tuple of cellvars.
775-
It's only valid when the *object* is a code object containing
775+
It's only valid when *source* is a code object containing
776776
:term:`free (closure) variables <closure variable>`.
777777
The length of the tuple must exactly match the length of the code object's
778778
:attr:`~codeobject.co_freevars` attribute.
@@ -2166,10 +2166,10 @@ are always available. They are listed here in alphabetical order.
21662166

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

21742174
There are two typical use cases for *super*. In a class hierarchy with
21752175
single inheritance, *super* can be used to refer to parent classes without
@@ -2428,10 +2428,9 @@ are always available. They are listed here in alphabetical order.
24282428
determine the package context of the :keyword:`import` statement.
24292429

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

24362435
When the *name* variable is of the form ``package.module``, normally, the
24372436
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
@@ -5667,7 +5667,7 @@ can be used interchangeably to index the same dictionary entry.
56675667

56685668
* Use a comma-separated list of ``key: value`` pairs within braces:
56695669
``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}``
5670-
* Use a dict comprehension: ``{}``, ``{x: x ** 2 for x in range(10)}``
5670+
* Use a dict comprehension: ``{x: x ** 2 for x in range(10)}``
56715671
* Use the type constructor: ``dict()``,
56725672
``dict([('foo', 100), ('bar', 200)])``, ``dict(foo=100, bar=200)``
56735673

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

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

58855884
>>> d = {'a': 1}
58865885
>>> 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)