Skip to content

Commit ccd1c2e

Browse files
committed
Merge branch 'main' into pythongh-114271-remove-tstate_lock
2 parents a7095e4 + 44f9a84 commit ccd1c2e

File tree

120 files changed

+2181
-812
lines changed

Some content is hidden

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

120 files changed

+2181
-812
lines changed

.github/workflows/build.yml

+10
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,14 @@ jobs:
301301
- name: SSL tests
302302
run: ./python Lib/test/ssltests.py
303303

304+
build_wasi:
305+
name: 'WASI'
306+
needs: check_source
307+
if: needs.check_source.outputs.run_tests == 'true'
308+
uses: ./.github/workflows/reusable-wasi.yml
309+
with:
310+
config_hash: ${{ needs.check_source.outputs.config_hash }}
311+
304312
test_hypothesis:
305313
name: "Hypothesis tests on Ubuntu"
306314
runs-on: ubuntu-20.04
@@ -525,6 +533,7 @@ jobs:
525533
- build_ubuntu
526534
- build_ubuntu_free_threading
527535
- build_ubuntu_ssltests
536+
- build_wasi
528537
- build_windows
529538
- build_windows_free_threading
530539
- test_hypothesis
@@ -558,6 +567,7 @@ jobs:
558567
build_ubuntu,
559568
build_ubuntu_free_threading,
560569
build_ubuntu_ssltests,
570+
build_wasi,
561571
build_windows,
562572
build_windows_free_threading,
563573
build_asan,

.github/workflows/reusable-wasi.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
config_hash:
5+
required: true
6+
type: string
7+
8+
jobs:
9+
build_wasi_reusable:
10+
name: 'build and test'
11+
timeout-minutes: 60
12+
runs-on: ubuntu-20.04
13+
env:
14+
WASMTIME_VERSION: 18.0.2
15+
WASI_SDK_VERSION: 20
16+
WASI_SDK_PATH: /opt/wasi-sdk
17+
CROSS_BUILD_PYTHON: cross-build/build
18+
CROSS_BUILD_WASI: cross-build/wasm32-wasi
19+
steps:
20+
- uses: actions/checkout@v4
21+
# No problem resolver registered as one doesn't currently exist for Clang.
22+
- name: "Install wasmtime"
23+
uses: jcbhmr/setup-wasmtime@v2
24+
with:
25+
wasmtime-version: ${{ env.WASMTIME_VERSION }}
26+
- name: "Restore WASI SDK"
27+
id: cache-wasi-sdk
28+
uses: actions/cache@v4
29+
with:
30+
path: ${{ env.WASI_SDK_PATH }}
31+
key: ${{ runner.os }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}
32+
- name: "Install WASI SDK"
33+
if: steps.cache-wasi-sdk.outputs.cache-hit != 'true'
34+
run: |
35+
mkdir ${{ env.WASI_SDK_PATH }} && \
36+
curl -s -S --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${{ env.WASI_SDK_VERSION }}/wasi-sdk-${{ env.WASI_SDK_VERSION }}.0-linux.tar.gz | \
37+
tar --strip-components 1 --directory ${{ env.WASI_SDK_PATH }} --extract --gunzip
38+
- name: "Configure ccache action"
39+
uses: hendrikmuhs/[email protected]
40+
with:
41+
save: ${{ github.event_name == 'push' }}
42+
max-size: "200M"
43+
- name: "Add ccache to PATH"
44+
run: echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
45+
- name: "Install Python"
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: '3.x'
49+
- name: "Restore Python build config.cache"
50+
uses: actions/cache@v4
51+
with:
52+
path: ${{ env.CROSS_BUILD_PYTHON }}/config.cache
53+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
54+
- name: "Configure build Python"
55+
run: python3 Tools/wasm/wasi.py configure-build-python -- --config-cache --with-pydebug
56+
- name: "Make build Python"
57+
run: python3 Tools/wasm/wasi.py make-build-python
58+
- name: "Restore host config.cache"
59+
uses: actions/cache@v4
60+
with:
61+
path: ${{ env.CROSS_BUILD_WASI }}/config.cache
62+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}-${{ inputs.config_hash }}
63+
- name: "Configure host"
64+
# `--with-pydebug` inferred from configure-build-python
65+
run: python3 Tools/wasm/wasi.py configure-host -- --config-cache
66+
- name: "Make host"
67+
run: python3 Tools/wasm/wasi.py make-host
68+
- name: "Display build info"
69+
run: make --directory ${{ env.CROSS_BUILD_WASI }} pythoninfo
70+
- name: "Test"
71+
run: make --directory ${{ env.CROSS_BUILD_WASI }} test

Doc/c-api/hash.rst

+24-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
PyHash API
44
----------
55

6-
See also the :c:member:`PyTypeObject.tp_hash` member.
6+
See also the :c:member:`PyTypeObject.tp_hash` member and :ref:`numeric-hash`.
77

88
.. c:type:: Py_hash_t
99
@@ -17,6 +17,29 @@ See also the :c:member:`PyTypeObject.tp_hash` member.
1717

1818
.. versionadded:: 3.2
1919

20+
.. c:macro:: PyHASH_MODULUS
21+
22+
The `Mersenne prime <https://en.wikipedia.org/wiki/Mersenne_prime>`_ ``P = 2**n -1``, used for numeric hash scheme.
23+
24+
.. versionadded:: 3.13
25+
26+
.. c:macro:: PyHASH_BITS
27+
28+
The exponent ``n`` of ``P`` in :c:macro:`PyHASH_MODULUS`.
29+
30+
.. versionadded:: 3.13
31+
32+
.. c:macro:: PyHASH_INF
33+
34+
The hash value returned for a positive infinity.
35+
36+
.. versionadded:: 3.13
37+
38+
.. c:macro:: PyHASH_IMAG
39+
40+
The multiplier used for the imaginary part of a complex number.
41+
42+
.. versionadded:: 3.13
2043

2144
.. c:type:: PyHash_FuncDef
2245

Doc/library/asyncio-eventloop.rst

+25
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,31 @@ Do not instantiate the :class:`Server` class directly.
16411641
coroutine to wait until the server is closed (and no more
16421642
connections are active).
16431643

1644+
.. method:: close_clients()
1645+
1646+
Close all existing incoming client connections.
1647+
1648+
Calls :meth:`~asyncio.BaseTransport.close` on all associated
1649+
transports.
1650+
1651+
:meth:`close` should be called before :meth:`close_clients` when
1652+
closing the server to avoid races with new clients connecting.
1653+
1654+
.. versionadded:: 3.13
1655+
1656+
.. method:: abort_clients()
1657+
1658+
Close all existing incoming client connections immediately,
1659+
without waiting for pending operations to complete.
1660+
1661+
Calls :meth:`~asyncio.WriteTransport.abort` on all associated
1662+
transports.
1663+
1664+
:meth:`close` should be called before :meth:`abort_clients` when
1665+
closing the server to avoid races with new clients connecting.
1666+
1667+
.. versionadded:: 3.13
1668+
16441669
.. method:: get_loop()
16451670

16461671
Return the event loop associated with the server object.

Doc/library/dataclasses.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ Using dataclasses, *if* this code was valid::
719719
class D:
720720
x: list = [] # This code raises ValueError
721721
def add(self, element):
722-
self.x += element
722+
self.x.append(element)
723723

724724
it would generate code similar to::
725725

@@ -728,7 +728,7 @@ it would generate code similar to::
728728
def __init__(self, x=x):
729729
self.x = x
730730
def add(self, element):
731-
self.x += element
731+
self.x.append(element)
732732

733733
assert D().x is D().x
734734

Doc/library/enum.rst

+7
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,20 @@ Data Types
279279
>>> Color.RED.value
280280
1
281281

282+
Value of the member, can be set in :meth:`~object.__new__`.
283+
282284
.. note:: Enum member values
283285

284286
Member values can be anything: :class:`int`, :class:`str`, etc. If
285287
the exact value is unimportant you may use :class:`auto` instances and an
286288
appropriate value will be chosen for you. See :class:`auto` for the
287289
details.
288290

291+
While mutable/unhashable values, such as :class:`dict`, :class:`list` or
292+
a mutable :class:`~dataclasses.dataclass`, can be used, they will have a
293+
quadratic performance impact during creation relative to the
294+
total number of mutable/unhashable values in the enum.
295+
289296
.. attribute:: Enum._name_
290297

291298
Name of the member.

Doc/library/resource.rst

+2
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ platform.
177177

178178
The largest area of mapped memory which the process may occupy.
179179

180+
.. availability:: FreeBSD >= 11.
181+
180182

181183
.. data:: RLIMIT_AS
182184

Doc/library/sys.rst

+20-25
Original file line numberDiff line numberDiff line change
@@ -1367,47 +1367,42 @@ always available.
13671367

13681368
.. data:: platform
13691369

1370-
This string contains a platform identifier that can be used to append
1371-
platform-specific components to :data:`sys.path`, for instance.
1372-
1373-
For Unix systems, except on Linux and AIX, this is the lowercased OS name as
1374-
returned by ``uname -s`` with the first part of the version as returned by
1375-
``uname -r`` appended, e.g. ``'sunos5'`` or ``'freebsd8'``, *at the time
1376-
when Python was built*. Unless you want to test for a specific system
1377-
version, it is therefore recommended to use the following idiom::
1378-
1379-
if sys.platform.startswith('freebsd'):
1380-
# FreeBSD-specific code here...
1381-
elif sys.platform.startswith('linux'):
1382-
# Linux-specific code here...
1383-
elif sys.platform.startswith('aix'):
1384-
# AIX-specific code here...
1385-
1386-
For other systems, the values are:
1370+
A string containing a platform identifier. Known values are:
13871371

13881372
================ ===========================
13891373
System ``platform`` value
13901374
================ ===========================
13911375
AIX ``'aix'``
1376+
Android ``'android'``
13921377
Emscripten ``'emscripten'``
1378+
iOS ``'ios'``
13931379
Linux ``'linux'``
1394-
WASI ``'wasi'``
1380+
macOS ``'darwin'``
13951381
Windows ``'win32'``
13961382
Windows/Cygwin ``'cygwin'``
1397-
macOS ``'darwin'``
1383+
WASI ``'wasi'``
13981384
================ ===========================
13991385

1386+
On Unix systems not listed in the table, the value is the lowercased OS name
1387+
as returned by ``uname -s``, with the first part of the version as returned by
1388+
``uname -r`` appended, e.g. ``'sunos5'`` or ``'freebsd8'``, *at the time
1389+
when Python was built*. Unless you want to test for a specific system
1390+
version, it is therefore recommended to use the following idiom::
1391+
1392+
if sys.platform.startswith('freebsd'):
1393+
# FreeBSD-specific code here...
1394+
14001395
.. versionchanged:: 3.3
14011396
On Linux, :data:`sys.platform` doesn't contain the major version anymore.
1402-
It is always ``'linux'``, instead of ``'linux2'`` or ``'linux3'``. Since
1403-
older Python versions include the version number, it is recommended to
1404-
always use the ``startswith`` idiom presented above.
1397+
It is always ``'linux'``, instead of ``'linux2'`` or ``'linux3'``.
14051398

14061399
.. versionchanged:: 3.8
14071400
On AIX, :data:`sys.platform` doesn't contain the major version anymore.
1408-
It is always ``'aix'``, instead of ``'aix5'`` or ``'aix7'``. Since
1409-
older Python versions include the version number, it is recommended to
1410-
always use the ``startswith`` idiom presented above.
1401+
It is always ``'aix'``, instead of ``'aix5'`` or ``'aix7'``.
1402+
1403+
.. versionchanged:: 3.13
1404+
On Android, :data:`sys.platform` now returns ``'android'`` rather than
1405+
``'linux'``.
14111406

14121407
.. seealso::
14131408

0 commit comments

Comments
 (0)