Skip to content

Commit 466b431

Browse files
authored
Docs: correct built-in exception, function, and dictionary descriptions (GH-160979)
(cherry picked from commit 3fb88e9)
1 parent 8e220a1 commit 466b431

3 files changed

Lines changed: 13 additions & 21 deletions

File tree

‎Doc/builtins/exceptions.rst‎

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

389389
.. attribute:: strerror
390390

391-
The corresponding error message, as provided by
392-
the operating system. It is formatted by the C
393-
functions :c:func:`!perror` under POSIX, and :c:func:`!FormatMessage`
394-
under Windows.
391+
The corresponding error message, as provided by the operating system.
392+
Under POSIX, it is obtained using the C functions :c:func:`!strerror`
393+
or :c:func:`!strerror_r`; under Windows, :c:func:`!FormatMessage` is used.
395394

396395
.. attribute:: filename
397396
filename2
@@ -552,11 +551,6 @@ The following exceptions are the exceptions that are usually raised.
552551
The column in the end line where the error occurred finishes. This is
553552
1-indexed: the first character in the line has an ``offset`` of 1.
554553

555-
For errors in f-string fields, the message is prefixed by "f-string: "
556-
and the offsets are offsets in a text constructed from the replacement
557-
expression. For example, compiling f'Bad {a b} field' results in this
558-
args attribute: ('f-string: ...', ('', 1, 2, '(a b)\n', 1, 5)).
559-
560554
.. versionchanged:: 3.10
561555
Added the :attr:`end_lineno` and :attr:`end_offset` attributes.
562556

‎Doc/builtins/functions.rst‎

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

719719
The *closure* argument specifies a closure--a tuple of cellvars.
720-
It's only valid when the *object* is a code object containing
720+
It's only valid when *source* is a code object containing
721721
:term:`free (closure) variables <closure variable>`.
722722
The length of the tuple must exactly match the length of the code object's
723723
:attr:`~codeobject.co_freevars` attribute.
@@ -2025,10 +2025,10 @@ are always available. They are listed here in alphabetical order.
20252025

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

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

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

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

53335333
* Use a comma-separated list of ``key: value`` pairs within braces:
53345334
``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}``
5335-
* Use a dict comprehension: ``{}``, ``{x: x ** 2 for x in range(10)}``
5335+
* Use a dict comprehension: ``{x: x ** 2 for x in range(10)}``
53365336
* Use the type constructor: ``dict()``,
53375337
``dict([('foo', 100), ('bar', 200)])``, ``dict(foo=100, bar=200)``
53385338

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

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

55505549
>>> d = {'a': 1}
55515550
>>> d.values() == d.values()

0 commit comments

Comments
 (0)