8000 Merge branch 'main' into long_export · python/cpython@a72ff83 · GitHub
[go: up one dir, main page]

Skip to content

Commit a72ff83

Browse files
committed
Merge branch 'main' into long_export
2 parents 94d852e + 2041a95 commit a72ff83

File tree

278 files changed

+7185
-3329
lines changed

Some content is hidden

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

278 files changed

+7185
-3329
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ jobs:
120120
- name: Build CPython
121121
run: |
122122
make -j4 regen-all
123-
make regen-stdlib-module-names regen-sbom
123+
make regen-stdlib-module-names regen-sbom regen-unicodedata
124124
- name: Check for changes
125125
run: |
126126
git add -u
@@ -235,10 +235,19 @@ jobs:
235235
free-threading:
236236
- false
237237
- true
238+
os:
239+
- ubuntu-24.04
240+
- ubuntu-24.04-aarch64
241+
is-fork: # only used for the exclusion trick
242+
- ${{ github.repository_owner != 'python' }}
243+
exclude:
244+
- os: ubuntu-24.04-aarch64
245+
is-fork: true
238246
uses: ./.github/workflows/reusable-ubuntu.yml
239247
with:
240248
config_hash: ${{ needs.check_source.outputs.config_hash }}
241249
free-threading: ${{ matrix.free-threading }}
250+
os: ${{ matrix.os }}
242251

243252
build_ubuntu_ssltests:
244253
name: 'Ubuntu SSL tests with OpenSSL'

.github/workflows/jit.yml

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ concurrency:
2828
jobs:
2929
interpreter:
3030
name: Interpreter (Debug)
31-
runs-on: ubuntu-22.04
31+
runs-on: ubuntu-24.04
3232
timeout-minutes: 90
3333
steps:
3434
- uses: actions/checkout@v4
@@ -78,10 +78,11 @@ jobs:
7878
runner: macos-14
7979
- target: x86_64-unknown-linux-gnu/gcc
8080
architecture: x86_64
81-
runner: ubuntu-22.04
81+
runner: ubuntu-24.04
8282
- target: aarch64-unknown-linux-gnu/gcc
8383
architecture: aarch64
84-
runner: ubuntu-22.04
84+
# Forks don't have access to our paid AArch64 runners. These jobs are skipped below:
85+
runner: ${{ github.repository_owner == 'python' && 'ubuntu-24.04-aarch64' || 'ubuntu-24.04' }}
8586
steps:
8687
- uses: actions/checkout@v4
8788
- uses: actions/setup-python@v5
@@ -104,7 +105,7 @@ jobs:
104105
105106
# The `find` line is required as a result of https://github.com/actions/runner-images/issues/9966.
106107
# This is a bug in the macOS runner image where the pre-installed Python is installed in the same
107-
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
108+
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
108109
# the symlink to the pre-installed Python so that the Homebrew Python is used instead.
109110
- name: Native macOS
110111
if: runner.os == 'macOS'
@@ -118,37 +119,19 @@ jobs:
118119
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
119120
120121
- name: Native Linux
121-
if: runner.os == 'Linux' && matrix.architecture == 'x86_64'
122+
# Forks don't have access to our paid AArch64 runners. Skip those:
123+
if: runner.os == 'Linux' && (matrix.architecture == 'x86_64' || github.repository_owner == 'python')
122124
run: |
123125
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
124126
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
125127
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '' }}
126128
make all --jobs 4
127129
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
128130
129-
- name: Emulated Linux
130-
if: runner.os == 'Linux' && matrix.architecture != 'x86_64'
131-
# The --ignorefile on ./python -m test is used to exclude tests known to fail when running on an emulated Linux.
132-
run: |
133-
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
134-
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
135-
./configure --prefix="$(pwd)/../build"
136-
make install --jobs 4
137-
make clean --jobs 4
138-
export HOST=${{ matrix.architecture }}-linux-gnu
139-
sudo apt install --yes "gcc-$HOST" qemu-user
140-
export QEMU_LD_PREFIX="/usr/$HOST"
141-
CC="$HOST-gcc" \
142-
CPP="$HOST-gcc --preprocess" \
143-
HOSTRUNNER=qemu-${{ matrix.architecture }} \
144-
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '' }} --build=x86_64-linux-gnu --host="$HOST" --with-build-python=../build/bin/python3 --with-pkg-config=no ac_cv_buggy_getaddrinfo=no ac_cv_file__dev_ptc=no ac_cv_file__dev_ptmx=yes
145-
make all --jobs 4
146-
./python -m test --ignorefile=Tools/jit/ignore-tests-emulated-linux.txt --multiprocess 0 --timeout 4500 --verbose2 --verbose3
147-
148131
jit-with-disabled-gil:
149132
name: Free-Threaded (Debug)
150133
needs: interpreter
151-
runs-on: ubuntu-22.04
134+
runs-on: ubuntu-24.04
152135
strategy:
153136
matrix:
154137
llvm:

.github/workflows/reusable-macos.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ jobs:
3737
path: config.cache
3838
key: ${{ github.job }}-${{ inputs.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
3939
- name: Install Homebrew dependencies
40-
run: brew install pkg-config openssl@3.0 xz gdbm tcl-tk make
40+
run: |
41+
brew install pkg-config openssl@3.0 xz gdbm tcl-tk@8 make
42+
# Because alternate versions are not symlinked into place by default:
43+
brew link tcl-tk@8
4144
- name: Configure CPython
4245
run: |
4346
GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \

.github/workflows/reusable-ubuntu.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ on:
1111
required: false
1212
type: boolean
1313
default: false
14+
os:
15+
description: OS to run the job
16+
required: true
17+
type: string
1418

1519
jobs:
1620
build_ubuntu_reusable:
17-
name: 'build and test'
21+
name: build and test (${{ inputs.os }})
1822
timeout-minutes: 60
19-
runs-on: ${{ matrix.os }}
20-
strategy:
21-
fail-fast: false
22-
matrix:
23-
os: [ubuntu-24.04, ubuntu-24.04-aarch64]
23+
runs-on: ${{ inputs.os }}
2424
env:
2525
FORCE_COLOR: 1
2626
OPENSSL_VER: 3.0.15
@@ -42,7 +42,7 @@ jobs:
4242
uses: actions/cache@v4
4343
with:
4444
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
45-
key: ${{ matrix.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
45+
key: ${{ inputs.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
4646
- name: Install OpenSSL
4747
if: steps.cache-openssl.outputs.cache-hit != 'true'
4848
run: python3 Tools/ssl/multissltests.py --steps=library --base-directory "$MULTISSL_DIR" --openssl "$OPENSSL_VER" --system Linux
@@ -84,7 +84,7 @@ jobs:
8484
working-directory: ${{ env.CPYTHON_BUILDDIR }}
8585
run: make -j
8686
- name: Build CPython out-of-tree (for compiler warning check)
87-
if: ${{ !inputs.free-threading}}
87+
if: ${{ !inputs.free-threading }}
8888
working-directory: ${{ env.CPYTHON_BUILDDIR }}
8989
run: set -o pipefail; make -j --output-sync 2>&1 | tee compiler_output_ubuntu.txt
9090
- name: Display build info

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pydoc-topics: build
144144

145145
.PHONY: gettext
146146
gettext: BUILDER = gettext
147-
gettext: SPHINXOPTS += -d build/doctrees-gettext
147+
gettext: override SPHINXOPTS := -d build/doctrees-gettext $(SPHINXOPTS)
148148
gettext: build
149149

150150
.PHONY: htmlview

Doc/c-api/exceptions.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,12 +853,23 @@ The following functions are used to create and modify Unicode exceptions from C.
853853
*\*start*. *start* must not be ``NULL``. Return ``0`` on success, ``-1`` on
854854
failure.
855855
856+
If the :attr:`UnicodeError.object` is an empty sequence, the resulting
857+
*start* is ``0``. Otherwise, it is clipped to ``[0, len(object) - 1]``.
858+
859+
.. seealso:: :attr:`UnicodeError.start`
860+
856861
.. c:function:: int PyUnicodeDecodeError_SetStart(PyObject *exc, Py_ssize_t start)
857862
int PyUnicodeEncodeError_SetStart(PyObject *exc, Py_ssize_t start)
858863
int PyUnicodeTranslateError_SetStart(PyObject *exc, Py_ssize_t start)
859864
860-
Set the *start* attribute of the given exception object to *start*. Return
861-
``0`` on success, ``-1`` on failure.
865+
Set the *start* attribute of the given exception object to *start*.
866+
Return ``0`` on success, ``-1`` on failure.
867+
868+
.. note::
869+
870+
While passing a negative *start* does not raise an exception,
871+
the corresponding getters will not consider it as a relative
872+
offset.
862873
863874
.. c:function:: int PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
864875
int PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
@@ -868,13 +879,18 @@ The following functions are used to create and modify Unicode exceptions from C.
868879
*\*end*. *end* must not be ``NULL``. Return ``0`` on success, ``-1`` on
869880
failure.
870881
882+
If the :attr:`UnicodeError.object` is an empty sequence, the resulting
883+
*end* is ``0``. Otherwise, it is clipped to ``[1, len(object)]``.
884+
871885
.. c:function:: int PyUnicodeDecodeError_SetEnd(PyObject *exc, Py_ssize_t end)
872886
int PyUnicodeEncodeError_SetEnd(PyObject *exc, Py_ssize_t end)
873887
int PyUnicodeTranslateError_SetEnd(PyObject *exc, Py_ssize_t end)
874888
875889
Set the *end* attribute of the given exception object to *end*. Return ``0``
876890
on success, ``-1`` on failure.
877891
892+
.. seealso:: :attr:`UnicodeError.end`
893+
878894
.. c:function:: PyObject* PyUnicodeDecodeError_GetReason(PyObject *exc)
879895
PyObject* PyUnicodeEncodeError_GetReason(PyObject *exc)
880896
PyObject* PyUnicodeTranslateError_GetReason(PyObject *exc)

Doc/c-api/init_config.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,15 @@ PyConfig
12811281
12821282
Default: ``1`` in Python config and ``0`` in isolated config.
12831283
1284+
.. c:member:: int use_system_logger
1285+
1286+
If non-zero, ``stdout`` and ``stderr`` will be redirected to the system
1287+
log.
1288+
1289+
Only available on macOS 10.12 and later, and on iOS.
1290+
1291+
Default: ``0`` (don't use system log).
1292+
12841293
.. c:member:: int user_site_directory
12851294
12861295
If non-zero, add the user site directory to :data:`sys.path`.

Doc/c-api/object.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Object Protocol
8585
instead of the :func:`repr`.
8686
8787
88-
.. c:function:: int PyObject_HasAttrWithError(PyObject *o, const char *attr_name)
88+
.. c:function:: int PyObject_HasAttrWithError(PyObject *o, PyObject *attr_name)
8989
9090
Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise.
9191
This is equivalent to the Python expression ``hasattr(o, attr_name)``.

Doc/c-api/stable.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Limited C API
6666

6767
Python 3.2 introduced the *Limited API*, a subset of Python's C API.
6868
Extensions that only use the Limited API can be
69-
compiled once and work with multiple versions of Python.
69+
compiled once and be loaded on multiple versions of Python.
7070
Contents of the Limited API are :ref:`listed below <limited-api-list>`.
7171

7272
.. c:macro:: Py_LIMITED_API
@@ -76,7 +76,7 @@ Contents of the Limited API are :ref:`listed below <limited-api-list>`.
7676

7777
Define ``Py_LIMITED_API`` to the value of :c:macro:`PY_VERSION_HEX`
7878
corresponding to the lowest Python version your extension supports.
79-
The extension will work without recompilation with all Python 3 releases
79+
The extension will be ABI-compatible with all Python 3 releases
8080
from the specified one onward, and can use Limited API introduced up to that
8181
version.
8282

@@ -94,7 +94,15 @@ Stable ABI
9494
----------
9595

9696
To enable this, Python provides a *Stable ABI*: a set of symbols that will
97-
remain compatible across Python 3.x versions.
97+
remain ABI-compatible across Python 3.x versions.
98+
99+
.. note::
100+
101+
The Stable ABI prevents ABI issues, like linker errors due to missing
102+
symbols or data corruption due to changes in structure layouts or function
103+
signatures.
104+
However, other changes in Python can change the *behavior* of extensions.
105+
See Python's Backwards Compatibility Policy (:pep:`387`) for details.
98106

99107
The Stable ABI contains symbols exposed in the :ref:`Limited API
100108
<limited-c-api>`, but also other ones – for example, functions necessary to

Doc/c-api/type.rst

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -529,19 +529,19 @@ The following functions and structs are used to create
529529
530530
The following “offset” fields cannot be set using :c:type:`PyType_Slot`:
531531
532-
* :c:member:`~PyTypeObject.tp_weaklistoffset`
533-
(use :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)
534-
* :c:member:`~PyTypeObject.tp_dictoffset`
535-
(use :c:macro:`Py_TPFLAGS_MANAGED_DICT` instead if possible)
536-
* :c:member:`~PyTypeObject.tp_vectorcall_offset`
537-
(use ``"__vectorcalloffset__"`` in
538-
:ref:`PyMemberDef <pymemberdef-offsets>`)
539-
540-
If it is not possible to switch to a ``MANAGED`` flag (for example,
541-
for vectorcall or to support Python older than 3.12), specify the
542-
offset in :c:member:`Py_tp_members <PyTypeObject.tp_members>`.
543-
See :ref:`PyMemberDef documentation <pymemberdef-offsets>`
544-
for details.
532+
* :c:member:`~PyTypeObject.tp_weaklistoffset`
533+
(use :c:macro:`Py_TPFLAGS_MANAGED_WEAKREF` instead if possible)
534+
* :c:member:`~PyTypeObject.tp_dictoffset`
535+
(use :c:macro:`Py_TPFLAGS_MANAGED_DICT` instead if possible)
536+
* :c:member:`~PyTypeObject.tp_vectorcall_offset`
537+
(use ``"__vectorcalloffset__"`` in
538+
:ref:`PyMemberDef <pymemberdef-offsets>`)
539+
540+
If it is not possible to switch to a ``MANAGED`` flag (for example,
541+
for vectorcall or to support Python older than 3.12), specify the
542+
offset in :c:member:`Py_tp_members <PyTypeObject.tp_members>`.
543+
See :ref:`PyMemberDef documentation <pymemberdef-offsets>`
544+
for details.
545545
546546
The following internal fields cannot be set at all when creating a heap
547547
type:
@@ -557,20 +557,18 @@ The following functions and structs are used to create
557557
To avoid issues, use the *bases* argument of
558558
:c:func:`PyType_FromSpecWithBases` instead.
559559
560-
.. versionchanged:: 3.9
561-
562-
Slots in :c:type:`PyBufferProcs` may be set in the unlimited API.
560+
.. versionchanged:: 3.9
561+
Slots in :c:type:`PyBufferProcs` may be set in the unlimited API.
563562
564-
.. versionchanged:: 3.11
565-
:c:member:`~PyBufferProcs.bf_getbuffer` and
566-
:c:member:`~PyBufferProcs.bf_releasebuffer` are now available
567-
under the :ref:`limited API <limited-c-api>`.
563+
.. versionchanged:: 3.11
564+
:c:member:`~PyBufferProcs.bf_getbuffer` and
565+
:c:member:`~PyBufferProcs.bf_releasebuffer` are now available
566+
under the :ref:`limited API <limited-c-api>`.
568567
569-
.. versionchanged:: 3.14
570-
571-
The field :c:member:`~PyTypeObject.tp_vectorcall` can now set
572-
using ``Py_tp_vectorcall``. See the field's documentation
573-
for details.
568+
.. versionchanged:: 3.14
569+
The field :c:member:`~PyTypeObject.tp_vectorcall` can now set
570+
using ``Py_tp_vectorcall``. See the field's documentation
571+
for details.
574572
575573
.. c:member:: void *pfunc
576574

Doc/c-api/unicode.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,6 +1588,11 @@ object.
15881588
15891589
Create a Unicode writer instance.
15901590
1591+
*length* must be greater than or equal to ``0``.
1592+
1593+
If *length* is greater than ``0``, preallocate an internal buffer of
1594+
*length* characters.
1595+
15911596
Set an exception and return ``NULL`` on error.
15921597
< 10000 span class="pl-s1">
15931598
.. c:function:: PyObject* PyUnicodeWriter_Finish(PyUnicodeWriter *writer)
@@ -1596,12 +1601,16 @@ object.
15961601
15971602
Set an exception and return ``NULL`` on error.
15981603
1604+
The writer instance is invalid after this call.
1605+
15991606
.. c:function:: void PyUnicodeWriter_Discard(PyUnicodeWriter *writer)
16001607
16011608
Discard the internal Unicode buffer and destroy the writer instance.
16021609
16031610
If *writer* is ``NULL``, no operation is performed.
16041611
1612+
The writer instance is invalid after this call.
1613+
16051614
.. c:function:: int PyUnicodeWriter_WriteChar(PyUnicodeWriter *writer, Py_UCS4 ch)
16061615
16071616
Write the single Unicode character *ch* into *writer*.

Doc/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@
7878
.. |python_version_literal| replace:: ``Python {version}``
7979
.. |python_x_dot_y_literal| replace:: ``python{version}``
8080
.. |usr_local_bin_python_x_dot_y_literal| replace:: ``/usr/local/bin/python{version}``
81+
82+
.. Apparently this how you hack together a formatted link:
83+
(https://www.docutils.org/docs/ref/rst/directives.html#replacement-text)
84+
.. |FORCE_COLOR| replace:: ``FORCE_COLOR``
85+
.. _FORCE_COLOR: https://force-color.org/
86+
.. |NO_COLOR| replace:: ``NO_COLOR``
87+
.. _NO_COLOR: https://no-color.org/
8188
"""
8289

8390
# There are two options for replacing |today|. Either, you set today to some

0 commit comments

Comments
 (0)
0