Skip to content

Commit a26384d

Browse files
committed
Merge remote-tracking branch 'origin/main' into gh-158195-unpin-type-lock
2 parents d06b4af + 4b21d15 commit a26384d

147 files changed

Lines changed: 3398 additions & 694 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎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()

‎Doc/howto/annotations.rst‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,22 @@ If you use a class with a custom metaclass and access ``__annotations__``
243243
on the class, you may observe unexpected behavior; see
244244
:pep:`749 <749#pep749-metaclasses>` for some examples. You can avoid these
245245
quirks by using :func:`annotationlib.get_annotations` on Python 3.14+ or
246-
:func:`inspect.get_annotations` on Python 3.10+. On earlier versions of
247-
Python, you can avoid these bugs by accessing the annotations from the
248-
class's :attr:`~type.__dict__`
249-
(for example, ``cls.__dict__.get('__annotations__', None)``).
246+
:func:`inspect.get_annotations` on Python 3.10+.
247+
248+
.. note::
249+
250+
On Python 3.14 and later, annotations are evaluated lazily (see
251+
:pep:`649` and :pep:`749`), and how the annotations dict is stored in
252+
the class's :attr:`~type.__dict__` is a private implementation detail.
253+
Reading ``cls.__dict__.get('__annotations__', None)`` may therefore
254+
return ``None`` even when the class has annotations. On these versions,
255+
always use :func:`annotationlib.get_annotations` (or
256+
:func:`inspect.get_annotations`) rather than accessing
257+
:attr:`~type.__dict__` directly.
258+
259+
Only on Python 3.9 and earlier, where neither function is available, can you
260+
avoid these bugs by reading the annotations from the class's
261+
:attr:`~type.__dict__` (for example, ``cls.__dict__.get('__annotations__', None)``).
250262

251263
In some versions of Python, instances of classes may have an ``__annotations__``
252264
attribute. However, this is not supported functionality. If you need the

‎Doc/library/functools.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ The :mod:`!functools` module defines the following functions:
339339

340340
.. versionadded:: 3.14
341341

342+
.. versionchanged:: next
343+
``Placeholder`` is now a :class:`sentinel`.
344+
342345
.. function:: partial(func, /, *args, **keywords)
343346

344347
Return a new :ref:`partial object<partial-objects>` which when called

‎Doc/library/gzip.rst‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,13 @@ Once executed the :mod:`!gzip` module keeps the input file(s).
307307
Add a new command line interface with a usage.
308308
By default, when you will execute the CLI, the default compression level is 6.
309309

310+
.. versionchanged:: next
311+
312+
An existing output file is removed and created anew instead of being
313+
opened for writing, so a symbolic link at that name is replaced rather
314+
than followed. Like :program:`gzip`, the output file is created with the
315+
permission bits of the input file.
316+
310317
Command-line options
311318
^^^^^^^^^^^^^^^^^^^^
312319

‎Doc/library/inspect.rst‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
284284
| | | ``AGEN_SUSPENDED``, or |
285285
| | | ``AGEN_CLOSED`` |
286286
+-----------------+-------------------+---------------------------+
287+
| async generator | aga_gen | async generator driven by |
288+
| awaitable | | the awaitable returned |
289+
| | | from ``asend()``, |
290+
| | | ``athrow()``, or |
291+
| | | ``aclose()`` |
292+
+-----------------+-------------------+---------------------------+
287293
| coroutine | __name__ | name |
288294
+-----------------+-------------------+---------------------------+
289295
| | __qualname__ | qualified name |
@@ -360,6 +366,11 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
360366
Add ``gi_state`` attribute to generators, ``cr_state`` attribute to
361367
coroutines, and ``ag_state`` attribute to async generators.
362368

369+
.. versionchanged:: 3.16
370+
371+
Add ``aga_gen`` attribute to the awaitables returned by the ``asend()``,
372+
``athrow()`` and ``aclose()`` methods of async generators.
373+
363374
.. function:: getmembers(object[, predicate])
364375

365376
Return all the members of an object in a list of ``(name, value)``

‎Doc/library/numbers.rst‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ them to the same values. This may be subtle if there are two different
9393
extensions of the real numbers. See also :ref:`numeric-hash`.
9494

9595

96-
Adding More Numeric ABCs
96+
Adding more numeric ABCs
9797
~~~~~~~~~~~~~~~~~~~~~~~~
9898

9999
There are, of course, more possible ABCs for numbers, and this would
@@ -143,11 +143,12 @@ defined as::
143143

144144

145145
There are 5 different cases for a mixed-type operation on subclasses
146-
of :class:`Complex`. I'll refer to all of the above code that doesn't
147-
refer to ``MyIntegral`` and ``OtherTypeIKnowAbout`` as
148-
"boilerplate". ``a`` will be an instance of ``A``, which is a subtype
149-
of :class:`Complex` (``a : A <: Complex``), and ``b : B <:
150-
Complex``. I'll consider ``a + b``:
146+
of :class:`Complex`. All of the above code that doesn't refer to
147+
``MyIntegral`` and ``OtherTypeIKnowAbout`` is referred to as "boilerplate".
148+
149+
In this description, ``a`` is an instance of ``A`` and ``b`` is an
150+
instance of ``B``, where ``A`` and ``B`` are both subtypes of :class:`Complex`.
151+
Consider ``a + b``:
151152

152153
1. If ``A`` defines an :meth:`~object.__add__` which accepts ``b``, all is
153154
well.
@@ -162,13 +163,14 @@ Complex``. I'll consider ``a + b``:
162163
4. If it falls back to the boilerplate, there are no more possible
163164
methods to try, so this is where the default implementation
164165
should live.
165-
5. If ``B <: A``, Python tries ``B.__radd__`` before
166+
5. If ``B`` is a subtype of ``A``, Python tries ``B.__radd__`` before
166167
``A.__add__``. This is ok, because it was implemented with
167168
knowledge of ``A``, so it can handle those instances before
168169
delegating to :class:`Complex`.
169170

170-
If ``A <: Complex`` and ``B <: Real`` without sharing any other knowledge,
171-
then the appropriate shared operation is the one involving the built
171+
If ``A`` is a subtype of :class:`Complex` and ``B`` is a subtype of
172+
:class:`Real` without sharing any other knowledge, then the appropriate
173+
shared operation is the one involving the built
172174
in :class:`complex`, and both :meth:`~object.__radd__` s land there, so ``a+b
173175
== b+a``.
174176

‎Doc/library/urllib.error.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ The following exceptions are raised by :mod:`!urllib.error` as appropriate:
2727
:exc:`URLError` used to be a subtype of :exc:`IOError`, which is now an
2828
alias of :exc:`OSError`.
2929

30+
.. versionchanged:: 3.16
31+
The :attr:`~OSError.errno` and :attr:`~OSError.strerror` attributes are
32+
now set from :attr:`reason` when it is an :exc:`OSError`. On Windows,
33+
:attr:`~OSError.winerror` is set as well.
34+
3035

3136
.. exception:: HTTPError(url, code, msg, hdrs, fp)
3237

‎Doc/library/xml.dom.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,12 @@ inherits properties from :class:`Node`.
756756
Return the element with the given ID, or ``None``.
757757
Only attributes declared as being of type ID in the DTD
758758
or by :meth:`Element.setIdAttribute` are searched.
759+
If several elements have the same ID, the first one
760+
in document order is returned.
761+
762+
.. versionchanged:: next
763+
Previously, which of the elements with the same ID was returned
764+
was unspecified and could change between calls.
759765

760766

761767
.. method:: Document.getElementsByTagName(tagName)

0 commit comments

Comments
 (0)