Skip to content

Commit 1ffb9d6

Browse files
committed
Merge branch 'lazy-importlib' of github.com:brettcannon/cpython into lazy-importlib
2 parents a71ce97 + 9318daa commit 1ffb9d6

61 files changed

Lines changed: 1222 additions & 185 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/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.

Doc/license.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,3 +1216,52 @@ license::
12161216
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
12171217
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
12181218
DAMAGE.
1219+
1220+
1221+
Unicode Character Database
1222+
--------------------------
1223+
1224+
An extract of the `Unicode Character Database <https://www.unicode.org/ucd/>`__,
1225+
converted to an internal format, is used by the :mod:`unicodedata` module and
1226+
for the Unicode support of the :class:`str` type. The original Unicode data
1227+
files are distributed under the `Unicode License <https://www.unicode.org/license.txt>`__::
1228+
1229+
UNICODE LICENSE V3
1230+
1231+
COPYRIGHT AND PERMISSION NOTICE
1232+
1233+
Copyright © 1991-2026 Unicode, Inc.
1234+
1235+
NOTICE TO USER: Carefully read the following legal agreement. BY
1236+
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
1237+
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
1238+
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
1239+
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
1240+
1241+
Permission is hereby granted, free of charge, to any person obtaining a
1242+
copy of data files and any associated documentation (the "Data Files") or
1243+
software and any associated documentation (the "Software") to deal in the
1244+
Data Files or Software without restriction, including without limitation
1245+
the rights to use, copy, modify, merge, publish, distribute, and/or sell
1246+
copies of the Data Files or Software, and to permit persons to whom the
1247+
Data Files or Software are furnished to do so, provided that either (a)
1248+
this copyright and permission notice appear with all copies of the Data
1249+
Files or Software, or (b) this copyright and permission notice appear in
1250+
associated Documentation.
1251+
1252+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
1253+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1254+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
1255+
THIRD PARTY RIGHTS.
1256+
1257+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
1258+
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
1259+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
1260+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
1261+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
1262+
FILES OR SOFTWARE.
1263+
1264+
Except as contained in this notice, the name of a copyright holder shall
1265+
not be used in advertising or otherwise to promote the sale, use or other
1266+
dealings in these Data Files or Software without prior written
1267+
authorization of the copyright holder.

Doc/whatsnew/3.15.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,14 @@ Other language changes
873873
imports ``pkg.sub.mod``.
874874
(Contributed by Gregory P. Smith in :gh:`83065`.)
875875

876+
* File names of Stable ABI extensions that use the ``.so`` suffix may now
877+
include a multiarch tuple, for example, ``foo.abi3-x86-64-linux-gnu.so``.
878+
This permits stable ABI extensions for multiple architectures to be
879+
co-installed into the same directory, without clashing with each
880+
other, as regular dynamic extensions do.
881+
(Contributed by Stefano Rivera in :gh:`122931`.)
882+
883+
876884

877885
Default interactive shell
878886
=========================

Include/internal/pycore_interp_structs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,6 @@ struct _is {
977977
struct _obmalloc_state *obmalloc;
978978

979979
PyObject *audit_hooks;
980-
PyMutex audit_hooks_mutex;
981980
PyType_WatchCallback type_watchers[TYPE_MAX_WATCHERS];
982981
PyCode_WatchCallback code_watchers[CODE_MAX_WATCHERS];
983982
PyContext_WatchCallback context_watchers[CONTEXT_MAX_WATCHERS];

0 commit comments

Comments
 (0)