Skip to content

Commit 5fac6df

Browse files
authored
Merge branch 'main' into doc-asyncio-subprocess-returncode-in-shell
2 parents 93cdda2 + 5edfe55 commit 5fac6df

File tree

164 files changed

+3553
-933
lines changed

Some content is hidden

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

164 files changed

+3553
-933
lines changed

.github/CODEOWNERS

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,10 @@ Tools/patchcheck/ @AA-Turner
8080
# ----------------------------------------------------------------------------
8181

8282
# Autotools
83-
configure* @erlend-aasland @corona10 @AA-Turner
84-
Makefile.pre.in @erlend-aasland @AA-Turner
85-
Modules/Setup* @erlend-aasland @AA-Turner
83+
configure* @erlend-aasland @corona10 @AA-Turner @emmatyping
84+
Makefile.pre.in @erlend-aasland @AA-Turner @emmatyping
85+
Modules/Setup* @erlend-aasland @AA-Turner @emmatyping
86+
Modules/makesetup @emmatyping
8687
Tools/build/regen-configure.sh @AA-Turner
8788

8889

@@ -157,16 +158,16 @@ Lib/_osx_support.py @python/macos-team
157158
Lib/test/test__osx_support.py @python/macos-team
158159

159160
# WebAssembly
160-
Tools/wasm/README.md @brettcannon @freakboy3742
161+
Tools/wasm/README.md @brettcannon @freakboy3742 @emmatyping
161162

162163
# WebAssembly (Emscripten)
163-
Tools/wasm/config.site-wasm32-emscripten @freakboy3742
164-
Tools/wasm/emscripten @freakboy3742
164+
Tools/wasm/config.site-wasm32-emscripten @freakboy3742 @emmatyping
165+
Tools/wasm/emscripten @freakboy3742 @emmatyping
165166

166167
# WebAssembly (WASI)
167-
Tools/wasm/wasi-env @brettcannon
168-
Tools/wasm/wasi.py @brettcannon
169-
Tools/wasm/wasi @brettcannon
168+
Tools/wasm/wasi-env @brettcannon @emmatyping
169+
Tools/wasm/wasi.py @brettcannon @emmatyping
170+
Tools/wasm/wasi @brettcannon @emmatyping
170171

171172
# Windows
172173
PC/ @python/windows-team
@@ -603,9 +604,9 @@ Lib/test/test_zipfile/_path/ @jaraco
603604
Lib/zipfile/_path/ @jaraco
604605

605606
# Zstandard
606-
Lib/compression/zstd/ @AA-Turner
607-
Lib/test/test_zstd.py @AA-Turner
608-
Modules/_zstd/ @AA-Turner
607+
Lib/compression/zstd/ @AA-Turner @emmatyping
608+
Lib/test/test_zstd.py @AA-Turner @emmatyping
609+
Modules/_zstd/ @AA-Turner @emmatyping
609610

610611
# ----------------------------------------------------------------------------
611612

Android/android.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,12 +737,10 @@ def ci(context):
737737
# Prove the package is self-contained by using it to run the tests.
738738
shutil.unpack_archive(package_path, temp_dir)
739739

740-
# Arguments are similar to --fast-ci, but in single-process mode.
740+
# Randomization is disabled because order-dependent failures are
741+
# much less likely to pass on a rerun in single-process mode.
741742
launcher_args = ["--managed", "maxVersion", "-v"]
742-
test_args = [
743-
"--single-process", "--fail-env-changed", "--rerun", "--slowest",
744-
"--verbose3", "-u", "all,-cpu", "--timeout=600"
745-
]
743+
test_args = ["--fast-ci", "--single-process", "--no-randomize"]
746744
run(
747745
["./android.py", "test", *launcher_args, "--", *test_args],
748746
cwd=temp_dir

Doc/c-api/init.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,12 @@ code, or when embedding the Python interpreter:
10201020
interpreter lock is also shared by all threads, regardless of to which
10211021
interpreter they belong.
10221022
1023+
.. versionchanged:: 3.12
1024+
1025+
:pep:`684` introduced the possibility
1026+
of a :ref:`per-interpreter GIL <per-interpreter-gil>`.
1027+
See :c:func:`Py_NewInterpreterFromConfig`.
1028+
10231029
10241030
.. c:type:: PyThreadState
10251031
@@ -1711,6 +1717,8 @@ function. You can create and destroy them using the following functions:
17111717
haven't been explicitly destroyed at that point.
17121718
17131719
1720+
.. _per-interpreter-gil:
1721+
17141722
A Per-Interpreter GIL
17151723
---------------------
17161724
@@ -1722,7 +1730,7 @@ being blocked by other interpreters or blocking any others. Thus a
17221730
single Python process can truly take advantage of multiple CPU cores
17231731
when running Python code. The isolation also encourages a different
17241732
approach to concurrency than that of just using threads.
1725-
(See :pep:`554`.)
1733+
(See :pep:`554` and :pep:`684`.)
17261734
17271735
Using an isolated interpreter requires vigilance in preserving that
17281736
isolation. That especially means not sharing any objects or mutable

Doc/c-api/module.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,28 @@ The available slot types are:
388388
389389
.. versionadded:: 3.13
390390
391+
.. c:macro:: Py_mod_abi
392+
393+
A pointer to a :c:struct:`PyABIInfo` structure that describes the ABI that
394+
the extension is using.
395+
396+
When the module is loaded, the :c:struct:`!PyABIInfo` in this slot is checked
397+
using :c:func:`PyABIInfo_Check`.
398+
399+
A suitable :c:struct:`!PyABIInfo` variable can be defined using the
400+
:c:macro:`PyABIInfo_VAR` macro, as in:
401+
402+
.. code-block:: c
403+
404+
PyABIInfo_VAR(abi_info);
405+
406+
static PyModuleDef_Slot mymodule_slots[] = {
407+
{Py_mod_abi, &abi_info},
408+
...
409+
};
410+
411+
.. versionadded:: 3.15
412+
391413
392414
.. _moduledef-dynamic:
393415

Doc/c-api/stable.rst

Lines changed: 159 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
.. _stable:
44

5-
***************
6-
C API Stability
7-
***************
5+
***********************
6+
C API and ABI Stability
7+
***********************
88

99
Unless documented otherwise, Python's C API is covered by the Backwards
1010
Compatibility Policy, :pep:`387`.
@@ -199,6 +199,162 @@ This is the case with Windows and macOS releases from ``python.org`` and many
199199
third-party distributors.
200200

201201

202+
ABI Checking
203+
============
204+
205+
.. versionadded:: next
206+
207+
Python includes a rudimentary check for ABI compatibility.
208+
209+
This check is not comprehensive.
210+
It only guards against common cases of incompatible modules being
211+
installed for the wrong interpreter.
212+
It also does not take :ref:`platform incompatibilities <stable-abi-platform>`
213+
into account.
214+
It can only be done after an extension is successfully loaded.
215+
216+
Despite these limitations, it is recommended that extension modules use this
217+
mechanism, so that detectable incompatibilities raise exceptions rather than
218+
crash.
219+
220+
Most modules can use this check via the :c:data:`Py_mod_abi`
221+
slot and the :c:macro:`PyABIInfo_VAR` macro, for example like this:
222+
223+
.. code-block:: c
224+
225+
PyABIInfo_VAR(abi_info);
226+
227+
static PyModuleDef_Slot mymodule_slots[] = {
228+
{Py_mod_abi, &abi_info},
229+
...
230+
};
231+
232+
233+
The full API is described below for advanced use cases.
234+
235+
.. c:function:: int PyABIInfo_Check(PyABIInfo *info, const char *module_name)
236+
237+
Verify that the given *info* is compatible with the currently running
238+
interpreter.
239+
240+
Return 0 on success. On failure, raise an exception and return -1.
241+
242+
If the ABI is incompatible, the raised exception will be :py:exc:`ImportError`.
243+
244+
The *module_name* argument can be ``NULL``, or point to a NUL-terminated
245+
UTF-8-encoded string used for error messages.
246+
247+
Note that if *info* describes the ABI that the current code uses (as defined
248+
by :c:macro:`PyABIInfo_VAR`, for example), using any other Python C API
249+
may lead to crashes.
250+
In particular, it is not safe to examine the raised exception.
251+
252+
.. versionadded:: next
253+
254+
.. c:macro:: PyABIInfo_VAR(NAME)
255+
256+
Define a static :c:struct:`PyABIInfo` variable with the given *NAME* that
257+
describes the ABI that the current code will use.
258+
This macro expands to:
259+
260+
.. code-block:: c
261+
262+
static PyABIInfo NAME = {
263+
1, 0,
264+
PyABIInfo_DEFAULT_FLAGS,
265+
PY_VERSION_HEX,
266+
PyABIInfo_DEFAULT_ABI_VERSION
267+
}
268+
269+
.. versionadded:: next
270+
271+
.. c:type:: PyABIInfo
272+
273+
.. c:member:: uint8_t abiinfo_major_version
274+
275+
The major version of :c:struct:`PyABIInfo`. Can be set to:
276+
277+
* ``0`` to skip all checking, or
278+
* ``1`` to specify this version of :c:struct:`!PyABIInfo`.
279+
280+
.. c:member:: uint8_t abiinfo_minor_version
281+
282+
The major version of :c:struct:`PyABIInfo`.
283+
Must be set to ``0``; larger values are reserved for backwards-compatible
284+
future versions of :c:struct:`!PyABIInfo`.
285+
286+
.. c:member:: uint16_t flags
287+
288+
.. c:namespace:: NULL
289+
290+
This field is usually set to the following macro:
291+
292+
.. c:macro:: PyABIInfo_DEFAULT_FLAGS
293+
294+
Default flags, based on current values of macros such as
295+
:c:macro:`Py_LIMITED_API` and :c:macro:`Py_GIL_DISABLED`.
296+
297+
Alternately, the field can be set to to the following flags, combined
298+
by bitwise OR.
299+
Unused bits must be set to zero.
300+
301+
ABI variant -- one of:
302+
303+
.. c:macro:: PyABIInfo_STABLE
304+
305+
Specifies that the stable ABI is used.
306+
307+
.. c:macro:: PyABIInfo_INTERNAL
308+
309+
Specifies ABI specific to a particular build of CPython.
310+
Internal use only.
311+
312+
Free-threading compatibility -- one of:
313+
314+
.. c:macro:: PyABIInfo_FREETHREADED
315+
316+
Specifies ABI compatible with free-threading builds of CPython.
317+
(That is, ones compiled with :option:`--disable-gil`; with ``t``
318+
in :py:data:`sys.abiflags`)
319+
320+
.. c:macro:: PyABIInfo_GIL
321+
322+
Specifies ABI compatible with non-free-threading builds of CPython
323+
(ones compiled *without* :option:`--disable-gil`).
324+
325+
.. c:member:: uint32_t build_version
326+
327+
The version of the Python headers used to build the code, in the format
328+
used by :c:macro:`PY_VERSION_HEX`.
329+
330+
This can be set to ``0`` to skip any checks related to this field.
331+
This option is meant mainly for projects that do not use the CPython
332+
headers directly, and do not emulate a specific version of them.
333+
334+
.. c:member:: uint32_t abi_version
335+
336+
The ABI version.
337+
338+
For the Stable ABI, this field should be the value of
339+
:c:macro:`Py_LIMITED_API`
340+
(except if :c:macro:`Py_LIMITED_API` is ``3``; use
341+
:c:expr:`Py_PACK_VERSION(3, 2)` in that case).
342+
343+
Otherwise, it should be set to :c:macro:`PY_VERSION_HEX`.
344+
345+
It can also be set to ``0`` to skip any checks related to this field.
346+
347+
.. c:namespace:: NULL
348+
349+
.. c:macro:: PyABIInfo_DEFAULT_ABI_VERSION
350+
351+
The value that should be used for this field, based on current
352+
values of macros such as :c:macro:`Py_LIMITED_API`,
353+
:c:macro:`PY_VERSION_HEX` and :c:macro:`Py_GIL_DISABLED`.
354+
355+
.. versionadded:: next
356+
357+
202358
.. _limited-api-list:
203359

204360
Contents of Limited API

Doc/conf.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,6 @@
221221
('envvar', 'USER'),
222222
('envvar', 'USERNAME'),
223223
('envvar', 'USERPROFILE'),
224-
# Deprecated function that was never documented:
225-
('py:func', 'getargspec'),
226-
('py:func', 'inspect.getargspec'),
227-
# Undocumented modules that users shouldn't have to worry about
228-
# (implementation details of `os.path`):
229-
('py:mod', 'ntpath'),
230-
('py:mod', 'posixpath'),
231224
]
232225

233226
# Temporary undocumented names.
@@ -242,10 +235,7 @@
242235
('py:meth', '_SubParsersAction.add_parser'),
243236
# Attributes/methods/etc. that definitely should be documented better,
244237
# but are deferred for now:
245-
('py:attr', '__annotations__'),
246-
('py:meth', '__missing__'),
247238
('py:attr', '__wrapped__'),
248-
('py:meth', 'index'), # list.index, tuple.index, etc.
249239
]
250240

251241
# gh-106948: Copy standard C types declared in the "c:type" domain and C

Doc/data/stable_abi.dat

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/faq/design.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,9 @@ exhaustive test suites that exercise every line of code in a module.
591591
An appropriate testing discipline can help build large complex applications in
592592
Python as well as having interface specifications would. In fact, it can be
593593
better because an interface specification cannot test certain properties of a
594-
program. For example, the :meth:`!list.append` method is expected to add new elements
594+
program. For example, the :meth:`list.append` method is expected to add new elements
595595
to the end of some internal list; an interface specification cannot test that
596-
your :meth:`!list.append` implementation will actually do this correctly, but it's
596+
your :meth:`list.append` implementation will actually do this correctly, but it's
597597
trivial to check this property in a test suite.
598598

599599
Writing test suites is very helpful, and you might want to design your code to

Doc/faq/programming.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ There are two factors that produce this result:
454454
(the list), and both ``x`` and ``y`` refer to it.
455455
2) Lists are :term:`mutable`, which means that you can change their content.
456456

457-
After the call to :meth:`!append`, the content of the mutable object has
457+
After the call to :meth:`~sequence.append`, the content of the mutable object has
458458
changed from ``[]`` to ``[10]``. Since both the variables refer to the same
459459
object, using either name accesses the modified value ``[10]``.
460460

@@ -1397,9 +1397,9 @@ To see why this happens, you need to know that (a) if an object implements an
13971397
:meth:`~object.__iadd__` magic method, it gets called when the ``+=`` augmented
13981398
assignment
13991399
is executed, and its return value is what gets used in the assignment statement;
1400-
and (b) for lists, :meth:`!__iadd__` is equivalent to calling :meth:`!extend` on the list
1401-
and returning the list. That's why we say that for lists, ``+=`` is a
1402-
"shorthand" for :meth:`!list.extend`::
1400+
and (b) for lists, :meth:`!__iadd__` is equivalent to calling
1401+
:meth:`~sequence.extend` on the list and returning the list.
1402+
That's why we say that for lists, ``+=`` is a "shorthand" for :meth:`list.extend`::
14031403

14041404
>>> a_list = []
14051405
>>> a_list += [1]

Doc/glossary.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,8 +1251,9 @@ Glossary
12511251
The :class:`collections.abc.Sequence` abstract base class
12521252
defines a much richer interface that goes beyond just
12531253
:meth:`~object.__getitem__` and :meth:`~object.__len__`, adding
1254-
:meth:`!count`, :meth:`!index`, :meth:`~object.__contains__`, and
1255-
:meth:`~object.__reversed__`. Types that implement this expanded
1254+
:meth:`~sequence.count`, :meth:`~sequence.index`,
1255+
:meth:`~object.__contains__`, and :meth:`~object.__reversed__`.
1256+
Types that implement this expanded
12561257
interface can be registered explicitly using
12571258
:func:`~abc.ABCMeta.register`. For more documentation on sequence
12581259
methods generally, see

0 commit comments

Comments
 (0)