Skip to content

Commit 3cb3d15

Browse files
committed
Merge remote-tracking branch 'origin/main' into ctx_thread_inheritable_vars
2 parents 942f312 + 1ec5607 commit 3cb3d15

126 files changed

Lines changed: 2461 additions & 521 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.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,14 @@ PCbuild/*-pgo
124124
PCbuild/*.VC.db
125125
PCbuild/*.VC.opendb
126126
PCbuild/amd64/
127+
PCbuild/amd64t/
127128
PCbuild/arm32/
129+
PCbuild/arm32t/
128130
PCbuild/arm64/
131+
PCbuild/arm64t/
129132
PCbuild/obj/
130133
PCbuild/win32/
134+
PCbuild/win32t/
131135
Tools/unicode/data/
132136
/autom4te.cache
133137
/build/

Doc/c-api/sys.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ accessible to C code. They all work with the current interpreter thread's
433433
This function is safe to call before :c:func:`Py_Initialize`. When called
434434
after runtime initialization, existing audit hooks are notified and may
435435
silently abort the operation by raising an error subclassed from
436-
:class:`Exception` (other errors will not be silenced).
436+
:class:`RuntimeError` (other errors will not be silenced).
437437
438438
The hook function is always called with an :term:`attached thread state` by
439439
the Python interpreter that raised the event.
@@ -447,7 +447,7 @@ accessible to C code. They all work with the current interpreter thread's
447447
448448
If the interpreter is initialized, this function raises an auditing event
449449
``sys.addaudithook`` with no arguments. If any existing hooks raise an
450-
exception derived from :class:`Exception`, the new hook will not be
450+
exception derived from :class:`RuntimeError`, the new hook will not be
451451
added and the exception is cleared. As a result, callers cannot assume
452452
that their hook has been added unless they control all existing hooks.
453453
@@ -462,6 +462,11 @@ accessible to C code. They all work with the current interpreter thread's
462462
463463
.. versionadded:: 3.8
464464
465+
.. versionchanged:: 3.8.1
466+
467+
Exceptions derived from :class:`Exception` but not :class:`RuntimeError`
468+
are no longer suppressed.
469+
465470
466471
.. _processcontrol:
467472

Doc/library/asyncio-eventloop.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,12 @@ Do not instantiate the :class:`Server` class directly.
18731873
Wait until the :meth:`close` method completes and all active
18741874
connections have finished.
18751875

1876+
.. versionchanged:: 3.12
1877+
``wait_closed()`` now waits until the server is closed and
1878+
all active connections have finished. Previously, it returned
1879+
immediately if the server was already closed, even if
1880+
connections were still active.
1881+
18761882
.. attribute:: sockets
18771883

18781884
List of socket-like objects, ``asyncio.trsock.TransportSocket``, which

Doc/library/ctypes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,10 @@ like ``find_library("c")`` will fail and return ``None``.
18661866

18671867
.. availability:: Windows
18681868

1869+
.. soft-deprecated:: 3.16
1870+
This function now always returns ``None``, as there are no more
1871+
VC runtime DLLs that are a single file and supported by Microsoft.
1872+
18691873

18701874
.. _ctypes-listing-loaded-shared-libraries:
18711875

Doc/library/curses.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ Initialization and termination
129129
and return the previously current screen.
130130
Returns ``None`` if the previous screen was the one created by
131131
:func:`initscr`.
132+
Raises :exc:`error` if *screen* has no terminal,
133+
as is the case for a screen returned by :func:`new_prescr`.
132134

133135
.. versionadded:: next
134136

Doc/library/difflib.rst

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,18 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
4040
complicated way on how many elements the sequences have in common; best case
4141
time is linear.
4242

43-
**Automatic junk heuristic:** :class:`SequenceMatcher` supports a heuristic that
44-
automatically treats certain sequence items as junk. The heuristic counts how many
45-
times each individual item appears in the sequence. If an item's duplicates (after
46-
the first one) account for more than 1% of the sequence and the sequence is at least
47-
200 items long, this item is marked as "popular" and is treated as junk for
48-
the purpose of sequence matching. This heuristic can be turned off by setting
49-
the ``autojunk`` argument to ``False`` when creating the :class:`SequenceMatcher`.
43+
**Junk**: :class:`SequenceMatcher` accepts an ``isjunk`` predicate and an
44+
``autojunk`` flag. Items that are considered as junk will not be considered
45+
to find similar content blocks. This can produce better results for humans
46+
(typically breaking on whitespace) and faster (because it reduces the number
47+
of possible combinations). But it can also cause pathological cases where
48+
too many items considered junk cause an unexpectedly large (but correct)
49+
diff result.
50+
You should consider tuning them or turning them off depending on your data.
51+
Moreover, only the second sequence is inspected for junk. This causes the diff
52+
output to not be symmetrical.
53+
When ``autojunk=True``, it will consider as junk the items that account for more
54+
than 1% of the sequence, if it is at least 200 items long.
5055

5156
.. versionchanged:: 3.2
5257
Added the *autojunk* parameter.
@@ -558,16 +563,6 @@ The :class:`SequenceMatcher` class has this constructor:
558563
to try :meth:`quick_ratio` or :meth:`real_quick_ratio` first to get an
559564
upper bound.
560565

561-
.. note::
562-
563-
Caution: The result of a :meth:`ratio` call may depend on the order of
564-
the arguments. For instance::
565-
566-
>>> SequenceMatcher(None, 'tide', 'diet').ratio()
567-
0.25
568-
>>> SequenceMatcher(None, 'diet', 'tide').ratio()
569-
0.5
570-
571566

572567
.. method:: quick_ratio()
573568

Doc/library/exceptions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ The following exceptions are the exceptions that are usually raised.
215215

216216
The object that was accessed for the named attribute.
217217

218+
When possible, :attr:`name` and :attr:`obj` are set automatically.
219+
218220
.. versionchanged:: 3.10
219221
Added the :attr:`name` and :attr:`obj` attributes.
220222

Doc/library/logging.handlers.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,8 @@ supports sending logging messages to a remote or local Unix syslog.
631631
the form of a ``(host, port)`` tuple. If *address* is not specified,
632632
``('localhost', 514)`` is used. The address is used to open a socket. An
633633
alternative to providing a ``(host, port)`` tuple is providing an address as a
634-
string, for example '/dev/log'. In this case, a Unix domain socket is used to
634+
string or a :class:`bytes` object, for example '/dev/log'.
635+
In this case, a Unix domain socket is used to
635636
send the message to the syslog. If *facility* is not specified,
636637
:const:`LOG_USER` is used. The type of socket opened depends on the
637638
*socktype* argument, which defaults to :const:`socket.SOCK_DGRAM` and thus
@@ -664,6 +665,9 @@ supports sending logging messages to a remote or local Unix syslog.
664665
.. versionchanged:: 3.14
665666
*timeout* was added.
666667

668+
.. versionchanged:: next
669+
*address* can now be a :class:`bytes` object.
670+
667671
.. method:: close()
668672

669673
Closes the socket to the remote host.

Doc/library/stdtypes.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4876,8 +4876,9 @@ copying.
48764876
Cast a memoryview to a new format or shape. *shape* defaults to
48774877
``[byte_length//new_itemsize]``, which means that the result view
48784878
will be one-dimensional. The return value is a new memoryview, but
4879-
the buffer itself is not copied. Supported casts are 1D -> C-:term:`contiguous`
4880-
and C-contiguous -> 1D.
4879+
the buffer itself is not copied. Supported casts are
4880+
1D -> C-:term:`contiguous`, C-contiguous -> 1D, and
4881+
F-contiguous -> 1D.
48814882

48824883
The destination format is restricted to a single element native format in
48834884
:mod:`struct` syntax. One of the formats must be a byte format
@@ -4964,6 +4965,10 @@ copying.
49644965
.. versionchanged:: 3.5
49654966
The source format is no longer restricted when casting to a byte view.
49664967

4968+
.. versionchanged:: next
4969+
Casting a multi-dimensional F-contiguous view to a one-dimensional
4970+
view is now supported.
4971+
49674972
.. method:: count(value, /)
49684973

49694974
Count the number of occurrences of *value*.

Doc/library/test.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,59 @@ The :mod:`!test.support` module defines the following functions:
961961
:mod:`tracemalloc` is enabled.
962962

963963

964+
.. currentmodule:: test.support.isolation
965+
966+
.. decorator:: runInSubprocess()
967+
968+
Decorator that runs the decorated test in a fresh interpreter subprocess, in
969+
isolation, so that it does not share global or interpreter state with the
970+
rest of the test run. It can decorate a test method or a whole
971+
:class:`~unittest.TestCase` subclass. Decorated methods must take no extra
972+
arguments. A failure, error or skip in the subprocess is reported for the
973+
corresponding test, and individual :meth:`subtests
974+
<unittest.TestCase.subTest>` that fail or are skipped are reported
975+
individually. A reported failure or error shows the original subprocess
976+
traceback as the cause of the exception.
977+
978+
When a **method** is decorated, only that method runs in a subprocess; all
979+
fixtures (:meth:`~unittest.TestCase.setUp` / :meth:`~unittest.TestCase.tearDown`,
980+
:meth:`~unittest.TestCase.setUpClass` / :meth:`~unittest.TestCase.tearDownClass`
981+
and ``setUpModule()`` / ``tearDownModule()``) run both in the parent process
982+
(as usual) and in the subprocess around the method.
983+
984+
When a **class** is decorated, the whole class runs in a single subprocess,
985+
and :meth:`~unittest.TestCase.setUpClass`,
986+
:meth:`~unittest.TestCase.tearDownClass`, :meth:`~unittest.TestCase.setUp`
987+
and :meth:`~unittest.TestCase.tearDown` run once each in the subprocess and
988+
are skipped in the parent process. A failure or skip of
989+
:meth:`~unittest.TestCase.setUpClass` in the subprocess is reported for the
990+
whole class. ``setUpModule()`` cannot be controlled by a class decorator,
991+
so it still runs in the parent process too; test it with
992+
:data:`runningInSubprocess` if needed.
993+
994+
The subprocess inherits the enabled resources (``-u``), memory limit
995+
(``-M``) and verbosity (``-v``) of the parent test run, so that
996+
:func:`~test.support.requires_resource`, :func:`~test.support.requires`,
997+
:func:`~test.support.bigmemtest` and the like behave consistently in both
998+
processes.
999+
1000+
The test is skipped on platforms without subprocess support.
1001+
1002+
1003+
.. data:: runningInSubprocess
1004+
1005+
``True`` while the code runs in the isolated subprocess spawned by
1006+
:func:`runInSubprocess`, and ``False`` otherwise (including in the parent
1007+
process and in a normal, non-isolated test run). Fixtures such as
1008+
:meth:`~unittest.TestCase.setUp`, :meth:`~unittest.TestCase.tearDown`,
1009+
:meth:`~unittest.TestCase.setUpClass`, :meth:`~unittest.TestCase.tearDownClass`,
1010+
``setUpModule()`` and ``tearDownModule()`` can test it to choose which code
1011+
to run in the subprocess.
1012+
1013+
1014+
.. currentmodule:: test.support
1015+
1016+
9641017
.. function:: check_free_after_iterating(test, iter, cls, args=())
9651018

9661019
Assert instances of *cls* are deallocated after iterating.

0 commit comments

Comments
 (0)