Skip to content

Commit 0314273

Browse files
committed
Merge remote-tracking branch 'cpython/main' into pythongh-99726-2
2 parents a01fb67 + 0f89acf commit 0314273

File tree

155 files changed

+5303
-2289
lines changed

Some content is hidden

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

155 files changed

+5303
-2289
lines changed

.github/workflows/build.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,11 @@ jobs:
162162
- uses: actions/checkout@v3
163163
- name: Install Homebrew dependencies
164164
run: brew install pkg-config openssl@1.1 xz gdbm tcl-tk
165-
- name: Prepare Homebrew environment variables
166-
run: |
167-
echo "CFLAGS=-I$(brew --prefix gdbm)/include -I$(brew --prefix xz)/include" >> $GITHUB_ENV
168-
echo "LDFLAGS=-L$(brew --prefix gdbm)/lib -I$(brew --prefix xz)/lib" >> $GITHUB_ENV
169-
echo "PKG_CONFIG_PATH=$(brew --prefix openssl@1.1)/lib/pkgconfig:$(brew --prefix tcl-tk)/lib/pkgconfig" >> $GITHUB_ENV
170165
- name: Configure CPython
171166
run: |
167+
CFLAGS="-I$(brew --prefix gdbm)/include -I$(brew --prefix xz)/include" \
168+
LDFLAGS="-L$(brew --prefix gdbm)/lib -I$(brew --prefix xz)/lib" \
169+
PKG_CONFIG_PATH="$(brew --prefix tcl-tk)/lib/pkgconfig" \
172170
./configure \
173171
--with-pydebug \
174172
--prefix=/opt/python-dev \

Doc/bugs.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Click on the "New issue" button in the top bar to report a new issue.
7070
The submission form has two fields, "Title" and "Comment".
7171

7272
For the "Title" field, enter a *very* short description of the problem;
73-
less than ten words is good.
73+
fewer than ten words is good.
7474

7575
In the "Comment" field, describe the problem in detail, including what you
7676
expected to happen and what did happen. Be sure to include whether any

Doc/c-api/init.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ Process-wide parameters
818818
.. deprecated:: 3.11
819819
820820
821-
.. c:function:: w_char* Py_GetPythonHome()
821+
.. c:function:: wchar_t* Py_GetPythonHome()
822822
823823
Return the default "home", that is, the value set by a previous call to
824824
:c:func:`Py_SetPythonHome`, or the value of the :envvar:`PYTHONHOME`

Doc/howto/logging-cookbook.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2538,7 +2538,7 @@ should be logged, or the ``extra`` keyword parameter to indicate additional
25382538
contextual information to be added to the log). So you cannot directly make
25392539
logging calls using :meth:`str.format` or :class:`string.Template` syntax,
25402540
because internally the logging package uses %-formatting to merge the format
2541-
string and the variable arguments. There would no changing this while preserving
2541+
string and the variable arguments. There would be no changing this while preserving
25422542
backward compatibility, since all logging calls which are out there in existing
25432543
code will be using %-format strings.
25442544

Doc/library/asyncio-eventloop.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,8 @@ Opening network connections
524524
When a server's IPv4 path and protocol are working, but the server's
525525
IPv6 path and protocol are not working, a dual-stack client
526526
application experiences significant connection delay compared to an
527-
IPv4-only client. This is undesirable because it causes the dual-
528-
stack client to have a worse user experience. This document
527+
IPv4-only client. This is undesirable because it causes the
528+
dual-stack client to have a worse user experience. This document
529529
specifies requirements for algorithms that reduce this user-visible
530530
delay and provides an algorithm.
531531

Doc/library/decimal.rst

+84-84
Large diffs are not rendered by default.

Doc/library/fractions.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ another rational number, or from a string.
118118
.. method:: as_integer_ratio()
119119

120120
Return a tuple of two integers, whose ratio is equal
121-
to the Fraction and with a positive denominator.
121+
to the original Fraction. The ratio is in lowest terms
122+
and has a positive denominator.
122123

123124
.. versionadded:: 3.8
124125

Doc/library/functions.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ are always available. They are listed here in alphabetical order.
623623
.. function:: filter(function, iterable)
624624

625625
Construct an iterator from those elements of *iterable* for which *function*
626-
returns true. *iterable* may be either a sequence, a container which
626+
is true. *iterable* may be either a sequence, a container which
627627
supports iteration, or an iterator. If *function* is ``None``, the identity
628628
function is assumed, that is, all elements of *iterable* that are false are
629629
removed.
@@ -634,7 +634,7 @@ are always available. They are listed here in alphabetical order.
634634
``None``.
635635

636636
See :func:`itertools.filterfalse` for the complementary function that returns
637-
elements of *iterable* for which *function* returns false.
637+
elements of *iterable* for which *function* is false.
638638

639639

640640
.. class:: float(x=0.0)

Doc/library/functools.rst

+16
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ The :mod:`functools` module defines the following functions:
8686
The cached value can be cleared by deleting the attribute. This
8787
allows the *cached_property* method to run again.
8888

89+
The *cached_property* does not prevent a possible race condition in
90+
multi-threaded usage. The getter function could run more than once on the
91+
same instance, with the latest run setting the cached value. If the cached
92+
property is idempotent or otherwise not harmful to run more than once on an
93+
instance, this is fine. If synchronization is needed, implement the necessary
94+
locking inside the decorated getter function or around the cached property
95+
access.
96+
8997
Note, this decorator interferes with the operation of :pep:`412`
9098
key-sharing dictionaries. This means that instance dictionaries
9199
can take more space than usual.
@@ -110,6 +118,14 @@ The :mod:`functools` module defines the following functions:
110118
def stdev(self):
111119
return statistics.stdev(self._data)
112120

121+
122+
.. versionchanged:: 3.12
123+
Prior to Python 3.12, ``cached_property`` included an undocumented lock to
124+
ensure that in multi-threaded usage the getter function was guaranteed to
125+
run only once per instance. However, the lock was per-property, not
126+
per-instance, which could result in unacceptably high lock contention. In
127+
Python 3.12+ this locking is removed.
128+
113129
.. versionadded:: 3.8
114130

115131

Doc/library/inspect.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,9 @@ function.
802802

803803
.. attribute:: Parameter.kind
804804

805-
Describes how argument values are bound to the parameter. Possible values
806-
(accessible via :class:`Parameter`, like ``Parameter.KEYWORD_ONLY``):
805+
Describes how argument values are bound to the parameter. The possible
806+
values are accessible via :class:`Parameter` (like ``Parameter.KEYWORD_ONLY``),
807+
and support comparison and ordering, in the following order:
807808

808809
.. tabularcolumns:: |l|L|
809810

Doc/library/itertools.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ loops that truncate the stream.
398398
.. function:: filterfalse(predicate, iterable)
399399

400400
Make an iterator that filters elements from iterable returning only those for
401-
which the predicate is ``False``. If *predicate* is ``None``, return the items
401+
which the predicate is false. If *predicate* is ``None``, return the items
402402
that are false. Roughly equivalent to::
403403

404404
def filterfalse(predicate, iterable):
@@ -831,7 +831,7 @@ which incur interpreter overhead.
831831
return next(g, True) and not next(g, False)
832832

833833
def quantify(iterable, pred=bool):
834-
"Count how many times the predicate is true"
834+
"Count how many times the predicate is True"
835835
return sum(map(pred, iterable))
836836

837837
def ncycles(iterable, n):

Doc/library/mmap.rst

+11-3
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,19 @@ MAP_* Constants
370370
MAP_ANONYMOUS
371371
MAP_POPULATE
372372
MAP_STACK
373+
MAP_ALIGNED_SUPER
374+
MAP_CONCEAL
373375

374-
These are the various flags that can be passed to :meth:`mmap.mmap`. Note that some options might not be present on some systems.
376+
These are the various flags that can be passed to :meth:`mmap.mmap`. :data:`MAP_ALIGNED_SUPER`
377+
is only available at FreeBSD and :data:`MAP_CONCEAL` is only available at OpenBSD. Note
378+
that some options might not be present on some systems.
375379

376380
.. versionchanged:: 3.10
377-
Added MAP_POPULATE constant.
381+
Added :data:`MAP_POPULATE` constant.
378382

379383
.. versionadded:: 3.11
380-
Added MAP_STACK constant.
384+
Added :data:`MAP_STACK` constant.
385+
386+
.. versionadded:: 3.12
387+
Added :data:`MAP_ALIGNED_SUPER` constant.
388+
Added :data:`MAP_CONCEAL` constant.

Doc/library/platform.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Cross Platform
6363
string is returned if the value cannot be determined.
6464

6565

66-
.. function:: platform(aliased=0, terse=0)
66+
.. function:: platform(aliased=False, terse=False)
6767

6868
Returns a single string identifying the underlying platform with as much useful
6969
information as possible.

Doc/library/queue.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module implements all the required locking semantics.
1515

1616
The module implements three types of queue, which differ only in the order in
1717
which the entries are retrieved. In a :abbr:`FIFO (first-in, first-out)`
18-
queue, the first tasks added are the first retrieved. In a
18+
queue, the first tasks added are the first retrieved. In a
1919
:abbr:`LIFO (last-in, first-out)` queue, the most recently added entry is
2020
the first retrieved (operating like a stack). With a priority queue,
2121
the entries are kept sorted (using the :mod:`heapq` module) and the
@@ -57,7 +57,7 @@ The :mod:`queue` module defines the following classes and exceptions:
5757
*maxsize* is less than or equal to zero, the queue size is infinite.
5858

5959
The lowest valued entries are retrieved first (the lowest valued entry is the
60-
one that would be returned by ``min(entries)``). A typical pattern for
60+
one that would be returned by ``min(entries)``). A typical pattern for
6161
entries is a tuple in the form: ``(priority_number, data)``.
6262

6363
If the *data* elements are not comparable, the data can be wrapped in a class
@@ -127,8 +127,8 @@ provide the public methods described below.
127127

128128
.. method:: Queue.put(item, block=True, timeout=None)
129129

130-
Put *item* into the queue. If optional args *block* is true and *timeout* is
131-
``None`` (the default), block if necessary until a free slot is available. If
130+
Put *item* into the queue. If optional args *block* is true and *timeout* is
131+
``None`` (the default), block if necessary until a free slot is available. If
132132
*timeout* is a positive number, it blocks at most *timeout* seconds and raises
133133
the :exc:`Full` exception if no free slot was available within that time.
134134
Otherwise (*block* is false), put an item on the queue if a free slot is
@@ -143,7 +143,7 @@ provide the public methods described below.
143143

144144
.. method:: Queue.get(block=True, timeout=None)
145145

146-
Remove and return an item from the queue. If optional args *block* is true and
146+
Remove and return an item from the queue. If optional args *block* is true and
147147
*timeout* is ``None`` (the default), block if necessary until an item is available.
148148
If *timeout* is a positive number, it blocks at most *timeout* seconds and
149149
raises the :exc:`Empty` exception if no item was available within that time.
@@ -152,7 +152,7 @@ provide the public methods described below.
152152

153153
Prior to 3.0 on POSIX systems, and for all versions on Windows, if
154154
*block* is true and *timeout* is ``None``, this operation goes into
155-
an uninterruptible wait on an underlying lock. This means that no exceptions
155+
an uninterruptible wait on an underlying lock. This means that no exceptions
156156
can occur, and in particular a SIGINT will not trigger a :exc:`KeyboardInterrupt`.
157157

158158

@@ -184,7 +184,7 @@ fully processed by daemon consumer threads.
184184

185185
The count of unfinished tasks goes up whenever an item is added to the queue.
186186
The count goes down whenever a consumer thread calls :meth:`task_done` to
187-
indicate that the item was retrieved and all work on it is complete. When the
187+
indicate that the item was retrieved and all work on it is complete. When the
188188
count of unfinished tasks drops to zero, :meth:`join` unblocks.
189189

190190

@@ -227,7 +227,7 @@ SimpleQueue Objects
227227

228228
.. method:: SimpleQueue.empty()
229229

230-
Return ``True`` if the queue is empty, ``False`` otherwise. If empty()
230+
Return ``True`` if the queue is empty, ``False`` otherwise. If empty()
231231
returns ``False`` it doesn't guarantee that a subsequent call to get()
232232
will not block.
233233

Doc/library/re.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ The special characters are:
271271

272272
* To match a literal ``']'`` inside a set, precede it with a backslash, or
273273
place it at the beginning of the set. For example, both ``[()[\]{}]`` and
274-
``[]()[{}]`` will both match a parenthesis.
274+
``[]()[{}]`` will match a right bracket, as well as left bracket, braces,
275+
and parentheses.
275276

276277
.. .. index:: single: --; in regular expressions
277278
.. .. index:: single: &&; in regular expressions

Doc/library/stdtypes.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,8 @@ class`. In addition, it provides a few more methods:
602602

603603
.. method:: int.as_integer_ratio()
604604

605-
Return a pair of integers whose ratio is exactly equal to the original
606-
integer and with a positive denominator. The integer ratio of integers
605+
Return a pair of integers whose ratio is equal to the original
606+
integer and has a positive denominator. The integer ratio of integers
607607
(whole numbers) is always the integer as the numerator and ``1`` as the
608608
denominator.
609609

@@ -624,7 +624,7 @@ class`. float also has the following additional methods.
624624
.. method:: float.as_integer_ratio()
625625

626626
Return a pair of integers whose ratio is exactly equal to the
627-
original float and with a positive denominator. Raises
627+
original float. The ratio is in lowest terms and has a positive denominator. Raises
628628
:exc:`OverflowError` on infinities and a :exc:`ValueError` on
629629
NaNs.
630630

Doc/library/struct.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ ordering::
371371
>>> from struct import *
372372
>>> pack(">bhl", 1, 2, 3)
373373
b'\x01\x00\x02\x00\x00\x00\x03'
374-
>>> unpack('>bhl', b'\x01\x00\x02\x00\x00\x00\x03'
374+
>>> unpack('>bhl', b'\x01\x00\x02\x00\x00\x00\x03')
375375
(1, 2, 3)
376376
>>> calcsize('>bhl')
377377
7

Doc/library/turtle.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -2444,6 +2444,9 @@ The demo scripts are:
24442444
| planet_and_moon| simulation of | compound shapes, |
24452445
| | gravitational system | :class:`Vec2D` |
24462446
+----------------+------------------------------+-----------------------+
2447+
| rosette | a pattern from the wikipedia | :func:`clone`, |
2448+
| | article on turtle graphics | :func:`undo` |
2449+
+----------------+------------------------------+-----------------------+
24472450
| round_dance | dancing turtles rotating | compound shapes, clone|
24482451
| | pairwise in opposite | shapesize, tilt, |
24492452
| | direction | get_shapepoly, update |
@@ -2457,9 +2460,6 @@ The demo scripts are:
24572460
| two_canvases | simple design | turtles on two |
24582461
| | | canvases |
24592462
+----------------+------------------------------+-----------------------+
2460-
| wikipedia | a pattern from the wikipedia | :func:`clone`, |
2461-
| | article on turtle graphics | :func:`undo` |
2462-
+----------------+------------------------------+-----------------------+
24632463
| yinyang | another elementary example | :func:`circle` |
24642464
+----------------+------------------------------+-----------------------+
24652465

Doc/library/types.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ Coroutine Utility Functions
486486
The generator-based coroutine is still a :term:`generator iterator`,
487487
but is also considered to be a :term:`coroutine` object and is
488488
:term:`awaitable`. However, it may not necessarily implement
489-
the :meth:`__await__` method.
489+
the :meth:`~object.__await__` method.
490490

491491
If *gen_func* is a generator function, it will be modified in-place.
492492

Doc/library/typing.rst

+39-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ annotations. These include:
9191
*Introducing* :data:`LiteralString`
9292
* :pep:`681`: Data Class Transforms
9393
*Introducing* the :func:`@dataclass_transform<dataclass_transform>` decorator
94+
* :pep:`698`: Adding an override decorator to typing
95+
*Introducing* the :func:`@override<override>` decorator
9496

9597
.. _type-aliases:
9698

@@ -1588,7 +1590,7 @@ These are not used in annotations. They are building blocks for creating generic
15881590
methods, not their type signatures. For example, :class:`ssl.SSLObject`
15891591
is a class, therefore it passes an :func:`issubclass`
15901592
check against :data:`Callable`. However, the
1591-
:meth:`ssl.SSLObject.__init__` method exists only to raise a
1593+
``ssl.SSLObject.__init__`` method exists only to raise a
15921594
:exc:`TypeError` with a more informative message, therefore making
15931595
it impossible to call (instantiate) :class:`ssl.SSLObject`.
15941596

@@ -2722,6 +2724,42 @@ Functions and decorators
27222724
This wraps the decorator with something that wraps the decorated
27232725
function in :func:`no_type_check`.
27242726

2727+
2728+
.. decorator:: override
2729+
2730+
A decorator for methods that indicates to type checkers that this method
2731+
should override a method or attribute with the same name on a base class.
2732+
This helps prevent bugs that may occur when a base class is changed without
2733+
an equivalent change to a child class.
2734+
2735+
For example::
2736+
2737+
class Base:
2738+
def log_status(self)
2739+
2740+
class Sub(Base):
2741+
@override
2742+
def log_status(self) -> None: # Okay: overrides Base.log_status
2743+
...
2744+
2745+
@override
2746+
def done(self) -> None: # Error reported by type checker
2747+
...
2748+
2749+
There is no runtime checking of this property.
2750+
2751+
The decorator will set the ``__override__`` attribute to ``True`` on
2752+
the decorated object. Thus, a check like
2753+
``if getattr(obj, "__override__", False)`` can be used at runtime to determine
2754+
whether an object ``obj`` has been marked as an override. If the decorated object
2755+
does not support setting attributes, the decorator returns the object unchanged
2756+
without raising an exception.
2757+
2758+
See :pep:`698` for more details.
2759+
2760+
.. versionadded:: 3.12
2761+
2762+
27252763
.. decorator:: type_check_only
27262764

27272765
Decorator to mark a class or function to be unavailable at runtime.

0 commit comments

Comments
 (0)