Skip to content

Commit 2267c77

Browse files
Merge branch 'main' into gh-155894-doc-issue
2 parents 7bf8763 + 66d7c89 commit 2267c77

99 files changed

Lines changed: 3445 additions & 1710 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.

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ Tools/cases_generator/ @markshannon
223223
Python/assemble.c @markshannon @iritkatriel
224224
Python/codegen.c @markshannon @iritkatriel
225225
Python/compile.c @markshannon @iritkatriel
226-
Python/flowgraph.c @markshannon @iritkatriel
226+
Python/flowgraph.c @markshannon @iritkatriel @eclips4
227227
Python/instruction_sequence.c @iritkatriel
228228
Python/symtable.c @JelleZijlstra @carljm
229229

Doc/library/dataclasses.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ Module contents
262262
c = C()
263263
c.mylist += [1, 2, 3]
264264

265-
As shown above, the :const:`MISSING` value is a sentinel object used to
266-
detect if some parameters are provided by the user. This sentinel is
265+
As shown above, the :const:`MISSING` value is a :class:`sentinel` object
266+
used to detect if some parameters are provided by the user. This sentinel is
267267
used because ``None`` is a valid value for some parameters with
268268
a distinct meaning. No code should directly use the :const:`MISSING` value.
269269

@@ -528,11 +528,14 @@ Module contents
528528

529529
.. data:: MISSING
530530

531-
A sentinel value signifying a missing default or default_factory.
531+
A :class:`sentinel` object signifying a missing default or *default_factory*.
532+
533+
.. versionchanged:: 3.15
534+
:const:`!MISSING` is now a :class:`sentinel` object.
532535

533536
.. data:: KW_ONLY
534537

535-
A sentinel value used as a type annotation. Any fields after a
538+
A :class:`sentinel` object used as a type annotation. Any fields after a
536539
pseudo-field with the type of :const:`!KW_ONLY` are marked as
537540
keyword-only fields. Note that a pseudo-field of type
538541
:const:`!KW_ONLY` is otherwise completely ignored. This includes the
@@ -557,6 +560,9 @@ Module contents
557560

558561
.. versionadded:: 3.10
559562

563+
.. versionchanged:: 3.15
564+
:const:`!KW_ONLY` is now a :class:`sentinel` object.
565+
560566
.. exception:: FrozenInstanceError
561567

562568
Raised when an implicitly defined :meth:`~object.__setattr__` or

Doc/library/json.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ Encoders and Decoders
486486
+----------------------------------------+---------------+
487487
| Python | JSON |
488488
+========================================+===============+
489-
| dict | object |
489+
| dict, frozendict | object |
490490
+----------------------------------------+---------------+
491491
| list, tuple | array |
492492
+----------------------------------------+---------------+
@@ -504,6 +504,9 @@ Encoders and Decoders
504504
.. versionchanged:: 3.4
505505
Added support for int- and float-derived Enum classes.
506506

507+
.. versionchanged:: 3.15
508+
Added support for :class:`frozendict`.
509+
507510
To extend this to recognize other objects, subclass and implement a
508511
:meth:`~JSONEncoder.default` method with another method that returns a serializable object
509512
for ``o`` if possible, otherwise it should call the superclass implementation

Doc/library/stdtypes.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ A hexadecimal string takes the form::
706706

707707
[sign] ['0x'] integer ['.' fraction] ['p' exponent]
708708

709-
where the optional ``sign`` may by either ``+`` or ``-``, ``integer``
709+
where the optional ``sign`` may be either ``+`` or ``-``, ``integer``
710710
and ``fraction`` are strings of hexadecimal digits, and ``exponent``
711711
is a decimal integer with an optional leading sign. Case is not
712712
significant, and there must be at least one hexadecimal digit in
@@ -1345,7 +1345,7 @@ Mutable sequence types also support the following methods:
13451345
:no-typesetting:
13461346
.. method:: sequence.pop(index=-1, /)
13471347

1348-
Retrieve the item at *index* and also removes it from *sequence*.
1348+
Retrieve the item at *index* and also remove it from *sequence*.
13491349
By default, the last item in *sequence* is removed and returned.
13501350

13511351
.. method:: bytearray.remove(value, /)
@@ -2120,7 +2120,7 @@ expression support in the :mod:`re` module).
21202120
one character, ``False`` otherwise. Alphabetic characters are those characters defined
21212121
in the Unicode character database as "Letter", i.e., those with general category
21222122
property being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note that this is different
2123-
from the `Alphabetic property defined in the section 4.10 'Letters, Alphabetic, and
2123+
from the `Alphabetic property defined in section 4.10 'Letters, Alphabetic, and
21242124
Ideographic' of the Unicode Standard
21252125
<https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-4/#G91002>`__.
21262126
For example:
@@ -3044,7 +3044,7 @@ replacement field. For example::
30443044
'0.333333'
30453045
>>> f'{one_third:_^+10}'
30463046
'___+1/3___'
3047-
>>> >>> f'{one_third!r:_^20}'
3047+
>>> f'{one_third!r:_^20}'
30483048
'___Fraction(1, 3)___'
30493049
>>> f'{one_third = :~>10}~'
30503050
'one_third = ~~~~~~~1/3~'
@@ -3054,12 +3054,12 @@ replacement field. For example::
30543054
Template String Literals (t-strings)
30553055
------------------------------------
30563056

3057-
An :dfn:`t-string` (formally a :dfn:`template string literal`) is
3057+
A :dfn:`t-string` (formally a :dfn:`template string literal`) is
30583058
a string literal that is prefixed with ``t`` or ``T``.
30593059

30603060
These strings follow the same syntax and evaluation rules as
30613061
:ref:`formatted string literals <stdtypes-fstrings>`,
3062-
with for the following differences:
3062+
with the following differences:
30633063

30643064
* Rather than evaluating to a ``str`` object, template string literals evaluate
30653065
to a :class:`string.templatelib.Template` object.
@@ -3086,7 +3086,7 @@ with for the following differences:
30863086
The :class:`!Interpolation` instance for the expression will be created as
30873087
normal, except that :attr:`~string.templatelib.Interpolation.conversion` will
30883088
be set to '``r``' (:func:`repr`) by default.
3089-
If an explicit conversion or format specifier are provided,
3089+
If an explicit conversion or format specifier is provided,
30903090
this will override the default behaviour.
30913091

30923092

@@ -3463,7 +3463,7 @@ objects.
34633463

34643464
.. classmethod:: fromhex(string, /)
34653465

3466-
This :class:`bytearray` class method returns bytearray object, decoding
3466+
This :class:`bytearray` class method returns a bytearray object, decoding
34673467
the given string object. The string must contain two hexadecimal digits
34683468
per byte, with ASCII whitespace being ignored.
34693469

@@ -4427,7 +4427,7 @@ the ``%`` operator (modulo).
44274427
This is also known as the bytes *formatting* or *interpolation* operator.
44284428
Given ``format % values`` (where *format* is a bytes object), ``%`` conversion
44294429
specifications in *format* are replaced with zero or more elements of *values*.
4430-
The effect is similar to using the :c:func:`sprintf` in the C language.
4430+
The effect is similar to using the :c:func:`sprintf` function in the C language.
44314431

44324432
If *format* requires a single argument, *values* may be a single non-tuple
44334433
object. [5]_ Otherwise, *values* must be a tuple with exactly the number of
@@ -4628,7 +4628,7 @@ copying.
46284628
underlying data.
46294629

46304630
``len(view)`` is equal to the length of :meth:`~memoryview.tolist`, which
4631-
is the nested list representation of the view. If ``view.ndim = 1``,
4631+
is the nested list representation of the view. If ``view.ndim == 1``,
46324632
this is equal to the number of elements in the view.
46334633

46344634
.. versionchanged:: 3.12
@@ -4713,7 +4713,7 @@ copying.
47134713
:class:`collections.abc.Sequence`
47144714

47154715
.. versionchanged:: 3.5
4716-
memoryviews can now be indexed with tuple of integers.
4716+
memoryviews can now be indexed with a tuple of integers.
47174717

47184718
.. versionchanged:: 3.14
47194719
memoryview is now a :term:`generic type`.
@@ -6182,7 +6182,7 @@ enables cleaner type hinting syntax compared to subscripting :class:`typing.Unio
61826182

61836183
.. note::
61846184

6185-
The ``|`` operand cannot be used at runtime to define unions where one or
6185+
The ``|`` operator cannot be used at runtime to define unions where one or
61866186
more members is a forward reference. For example, ``int | "Foo"``, where
61876187
``"Foo"`` is a reference to a class not yet defined, will fail at
61886188
runtime. For unions which include forward references, present the
@@ -6341,7 +6341,7 @@ Methods
63416341
Methods are functions that are called using the attribute notation.
63426342
There are two flavors: :ref:`built-in methods <builtin-methods>`
63436343
(such as :meth:`~list.append` on lists)
6344-
and :ref:`class instance method <instance-methods>`.
6344+
and :ref:`class instance methods <instance-methods>`.
63456345
Built-in methods are described with the types that support them.
63466346

63476347
If you access a method (a function defined in a class namespace) through an

Doc/library/urllib.request.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,8 +987,14 @@ These methods are available on :class:`HTTPPasswordMgr` and
987987

988988
*uri* can be either a single URI, or a sequence of URIs. *realm*, *user* and
989989
*passwd* must be strings. This causes ``(user, passwd)`` to be used as
990-
authentication tokens when authentication for *realm* and a super-URI of any of
991-
the given URIs is given.
990+
authentication tokens when authentication for *realm* and a super-URI of any
991+
of the given URIs is given. If a URI includes a scheme, its credentials only
992+
match authentication URIs with the same scheme or no scheme. A URI without a
993+
scheme matches authentication URIs with any scheme.
994+
995+
.. versionchanged:: next
996+
Authentication credentials for URIs with a scheme are now scoped by
997+
that scheme.
992998

993999

9941000
.. method:: HTTPPasswordMgr.find_user_password(realm, authuri)

Doc/library/zipfile.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,9 @@ ZipFile objects
585585
strict_descriptor=True[, chunk_size])
586586

587587
Rewrites the archive to remove unreferenced local file entries, shrinking
588-
its file size. The archive must be opened with mode ``'a'``.
588+
its file size. The archive must be opened with mode ``'a'``, and any file
589+
object returned by :meth:`ZipFile.open` must be closed first, since
590+
repacking moves the member data such objects refer to.
589591

590592
If *removed* is provided, it must be a sequence of :class:`ZipInfo` objects
591593
representing the recently removed members, and only their corresponding

Lib/asyncio/selector_events.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,8 +1198,13 @@ def writelines(self, list_of_data):
11981198
return
11991199

12001200
for data in list_of_data:
1201+
# gh-155888: an empty chunk can never be drained, so never buffer it
1202+
if not data:
1203+
continue
12011204
self._buffer.append(memoryview(data))
12021205
self._buffer_size += len(data)
1206+
if not self._buffer:
1207+
return
12031208
self._write_ready()
12041209
# If the entire buffer couldn't be written, register a write handler
12051210
if self._buffer:

Lib/calendar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,11 +609,11 @@ def formatyearpage(self, theyear, width=3, css='calendar.css', encoding=None):
609609
content = self.formatyear(theyear, width)
610610
return self._format_html_page(theyear, content, css, encoding)
611611

612-
def formatmonthpage(self, theyear, themonth, width=3, css='calendar.css', encoding=None):
612+
def formatmonthpage(self, theyear, themonth, *, css='calendar.css', encoding=None):
613613
"""
614614
Return a formatted month as a complete HTML page.
615615
"""
616-
content = self.formatmonth(theyear, themonth, width)
616+
content = self.formatmonth(theyear, themonth)
617617
return self._format_html_page(theyear, content, css, encoding)
618618

619619

Lib/concurrent/futures/_base.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,13 @@ def wait(fs, timeout=None, return_when=ALL_COMPLETED):
309309
def _result_or_cancel(fut, timeout=None):
310310
try:
311311
try:
312-
return (fut.result(timeout), None)
313-
except TimeoutError:
314-
raise
315-
except BaseException as exc:
312+
# fut.exception() returns the call's own error but raises
313+
# TimeoutError only for a map() timeout.
314+
exc = fut.exception(timeout)
315+
if exc is not None:
316+
return (None, exc)
317+
return (fut.result(), None)
318+
except CancelledError as exc:
316319
return (None, exc)
317320
finally:
318321
fut.cancel()

Lib/concurrent/interpreters/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,14 @@ def create():
6868

6969
def list_all():
7070
"""Return all existing interpreters."""
71-
return [Interpreter(id, _whence=whence)
72-
for id, whence in _interpreters.list_all(require_ready=True)]
71+
interps = []
72+
for id, whence in _interpreters.list_all(require_ready=True):
73+
try:
74+
interps.append(Interpreter(id, _whence=whence))
75+
except InterpreterNotFoundError:
76+
# It was destroyed after it was listed.
77+
pass
78+
return interps
7379

7480

7581
def get_current():

0 commit comments

Comments
 (0)