Skip to content

Commit 9594f38

Browse files
committed
Merge branch 'main' of github.com:LindaSummer/cpython into bugfix/gh-127085
2 parents d348113 + 8fa5ece commit 9594f38

File tree

209 files changed

+4997
-2564
lines changed

Some content is hidden

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

209 files changed

+4997
-2564
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: 7 additions & 24 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
@@ -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-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/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/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/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
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

Doc/howto/free-threading-extensions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ that return :term:`strong references <strong reference>`.
167167
+-----------------------------------+-----------------------------------+
168168
| :c:func:`PyImport_AddModule` | :c:func:`PyImport_AddModuleRef` |
169169
+-----------------------------------+-----------------------------------+
170+
| :c:func:`PyCell_GET` | :c:func:`PyCell_Get` |
171+
+-----------------------------------+-----------------------------------+
170172

171173
Not all APIs that return borrowed references are problematic. For
172174
example, :c:func:`PyTuple_GetItem` is safe because tuples are immutable.

Doc/howto/gdb_helpers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ regular machine-level integer::
180180
(gdb) p some_python_integer
181181
$4 = 42
182182

183-
The internal structure can be revealed with a cast to :c:expr:`PyLongObject *`:
183+
The internal structure can be revealed with a cast to :c:expr:`PyLongObject *`::
184184

185185
(gdb) p *(PyLongObject*)some_python_integer
186186
$5 = {ob_base = {ob_base = {ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size = 1},

Doc/howto/logging.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ that; formatting options will also be explained later.
127127

128128
Notice that in this example, we use functions directly on the ``logging``
129129
module, like ``logging.debug``, rather than creating a logger and calling
130-
functions on it. These functions operation on the root logger, but can be useful
130+
functions on it. These functions operate on the root logger, but can be useful
131131
as they will call :func:`~logging.basicConfig` for you if it has not been called yet, like in
132132
this example. In larger programs you'll usually want to control the logging
133133
configuration explicitly however - so for that reason as well as others, it's

0 commit comments

Comments
 (0)