Skip to content

Commit 911d872

Browse files
authored
Merge branch 'main' into fix/xml/evil-find-126037
2 parents 3584ca9 + 5aaf416 commit 911d872

File tree

634 files changed

+25810
-11921
lines changed

Some content is hidden

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

634 files changed

+25810
-11921
lines changed

.github/CODEOWNERS

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,14 @@ Doc/library/site.rst @FFY00
9696
Lib/test/test_except*.py @iritkatriel
9797
Objects/exceptions.c @iritkatriel
9898

99-
# Hashing
100-
**/*hashlib* @gpshead @tiran
99+
# Hashing & cryptographic primitives
100+
**/*hashlib* @gpshead @tiran @picnixz
101101
**/*pyhash* @gpshead @tiran
102-
**/sha* @gpshead @tiran
103-
Modules/md5* @gpshead @tiran
104-
**/*blake* @gpshead @tiran
102+
**/sha* @gpshead @tiran @picnixz
103+
Modules/md5* @gpshead @tiran @picnixz
104+
**/*blake* @gpshead @tiran @picnixz
105105
Modules/_hacl/** @gpshead
106+
**/*hmac* @gpshead @picnixz
106107

107108
# logging
108109
**/*logging* @vsajip

.github/workflows/build.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
# reproducible: to get the same tools versions (autoconf, aclocal, ...)
4747
runs-on: ubuntu-24.04
4848
container:
49-
image: ghcr.io/python/autoconf:2024.11.11.11786316759
49+
image: ghcr.io/python/autoconf:2025.01.02.12581854023
5050
timeout-minutes: 60
5151
needs: check_source
5252
if: needs.check_source.outputs.run_tests == 'true'
@@ -63,7 +63,7 @@ jobs:
6363
run: echo "IMAGE_VERSION=${ImageVersion}" >> "$GITHUB_ENV"
6464
- name: Check Autoconf and aclocal versions
6565
run: |
66-
grep "Generated by GNU Autoconf 2.71" configure
66+
grep "Generated by GNU Autoconf 2.72" configure
6767
grep "aclocal 1.16.5" aclocal.m4
6868
grep -q "runstatedir" configure
6969
grep -q "PKG_PROG_PKG_CONFIG" aclocal.m4
@@ -231,10 +231,14 @@ jobs:
231231
name: >-
232232
Ubuntu
233233
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
234+
${{ fromJSON(matrix.bolt) && '(bolt)' || '' }}
234235
needs: check_source
235236
if: needs.check_source.outputs.run_tests == 'true'
236237
strategy:
237238
matrix:
239+
bolt:
240+
- false
241+
- true
238242
free-threading:
239243
- false
240244
- true
@@ -246,9 +250,16 @@ jobs:
246250
exclude:
247251
- os: ubuntu-24.04-aarch64
248252
is-fork: true
253+
# Do not test BOLT with free-threading, to conserve resources
254+
- bolt: true
255+
free-threading: true
256+
# BOLT currently crashes during instrumentation on aarch64
257+
- os: ubuntu-24.04-aarch64
258+
bolt: true
249259
uses: ./.github/workflows/reusable-ubuntu.yml
250260
with:
251261
config_hash: ${{ needs.check_source.outputs.config_hash }}
262+
bolt-optimizations: ${{ matrix.bolt }}
252263
free-threading: ${{ matrix.free-threading }}
253264
os: ${{ matrix.os }}
254265

.github/workflows/reusable-change-detection.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,22 @@ jobs:
8383
# into the PR branch anyway.
8484
#
8585
# https://github.com/python/core-workflow/issues/373
86-
git diff --name-only "origin/$GITHUB_BASE_REF.." | grep -qvE '(\.rst$|^Doc|^Misc|^\.pre-commit-config\.yaml$|\.ruff\.toml$|\.md$|mypy\.ini$)' && echo "run-tests=true" >> "$GITHUB_OUTPUT" || true
86+
grep_ignore_args=(
87+
# file extensions
88+
-e '\.md$'
89+
-e '\.rst$'
90+
# top-level folders
91+
-e '^Doc/'
92+
-e '^Misc/'
93+
# configuration files
94+
-e '^\.github/CODEOWNERS$'
95+
-e '^\.pre-commit-config\.yaml$'
96+
-e '\.ruff\.toml$'
97+
-e 'mypy\.ini$'
98+
)
99+
git diff --name-only "origin/$GITHUB_BASE_REF.." \
100+
| grep -qvE "${grep_ignore_args[@]}" \
101+
&& echo "run-tests=true" >> "$GITHUB_OUTPUT" || true
87102
fi
88103
89104
# Check if we should run hypothesis tests

.github/workflows/reusable-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ jobs:
9999
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
100100
doctest:
101101
name: 'Doctest'
102-
runs-on: ubuntu-22.04
102+
runs-on: ubuntu-24.04
103103
timeout-minutes: 60
104104
steps:
105105
- uses: actions/checkout@v4

.github/workflows/reusable-macos.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ jobs:
4242
run: |
4343
brew install pkg-config [email protected] xz gdbm tcl-tk@8 make
4444
# Because alternate versions are not symlinked into place by default:
45-
brew link tcl-tk@8
45+
brew link --overwrite tcl-tk@8
4646
- name: Configure CPython
4747
run: |
48+
MACOSX_DEPLOYMENT_TARGET=10.15 \
4849
GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \
4950
GDBM_LIBS="-L$(brew --prefix gdbm)/lib -lgdbm" \
5051
./configure \

.github/workflows/reusable-ubuntu.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
config_hash:
77
required: true
88
type: string
9+
bolt-optimizations:
10+
description: Whether to enable BOLT optimizations
11+
required: false
12+
type: boolean
13+
default: false
914
free-threading:
1015
description: Whether to use free-threaded mode
1116
required: false
@@ -34,6 +39,12 @@ jobs:
3439
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
3540
- name: Install dependencies
3641
run: sudo ./.github/workflows/posix-deps-apt.sh
42+
- name: Install Clang and BOLT
43+
if: ${{ fromJSON(inputs.bolt-optimizations) }}
44+
run: |
45+
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh 19
46+
sudo apt-get install bolt-19
47+
echo PATH="$(llvm-config-19 --bindir):$PATH" >> $GITHUB_ENV
3748
- name: Configure OpenSSL env vars
3849
run: |
3950
echo "MULTISSL_DIR=${GITHUB_WORKSPACE}/multissl" >> "$GITHUB_ENV"
@@ -73,14 +84,18 @@ jobs:
7384
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
7485
- name: Configure CPython out-of-tree
7586
working-directory: ${{ env.CPYTHON_BUILDDIR }}
87+
# `test_unpickle_module_race` writes to the source directory, which is
88+
# read-only during builds — so we exclude it from profiling with BOLT.
7689
run: >-
90+
PROFILE_TASK='-m test --pgo --ignore test_unpickle_module_race'
7791
../cpython-ro-srcdir/configure
7892
--config-cache
7993
--with-pydebug
8094
--enable-slower-safety
8195
--enable-safety
8296
--with-openssl="$OPENSSL_DIR"
8397
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
98+
${{ fromJSON(inputs.bolt-optimizations) && '--enable-bolt' || '' }}
8499
- name: Build CPython out-of-tree
85100
if: ${{ inputs.free-threading }}
86101
working-directory: ${{ env.CPYTHON_BUILDDIR }}

.pre-commit-config.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.8.2
3+
rev: v0.9.1
44
hooks:
55
- id: ruff
66
name: Run Ruff (lint) on Doc/
@@ -29,12 +29,10 @@ repos:
2929
- id: black
3030
name: Run Black on Tools/build/check_warnings.py
3131
files: ^Tools/build/check_warnings.py
32-
language_version: python3.12
3332
args: [--line-length=79]
3433
- id: black
3534
name: Run Black on Tools/jit/
3635
files: ^Tools/jit/
37-
language_version: python3.12
3836

3937
- repo: https://github.com/pre-commit/pre-commit-hooks
4038
rev: v5.0.0
@@ -51,18 +49,19 @@ repos:
5149
types_or: [c, inc, python, rst]
5250

5351
- repo: https://github.com/python-jsonschema/check-jsonschema
54-
rev: 0.30.0
52+
rev: 0.31.0
5553
hooks:
5654
- id: check-dependabot
5755
- id: check-github-workflows
56+
- id: check-readthedocs
5857

5958
- repo: https://github.com/rhysd/actionlint
60-
rev: v1.7.4
59+
rev: v1.7.6
6160
hooks:
6261
- id: actionlint
6362

6463
- repo: https://github.com/woodruffw/zizmor-pre-commit
65-
rev: v0.8.0
64+
rev: v1.1.1
6665
hooks:
6766
- id: zizmor
6867

Doc/about.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
=====================
2-
About these documents
3-
=====================
1+
========================
2+
About this documentation
3+
========================
44

55

6-
These documents are generated from `reStructuredText`_ sources by `Sphinx`_, a
7-
document processor specifically written for the Python documentation.
6+
Python's documentation is generated from `reStructuredText`_ sources
7+
using `Sphinx`_, a documentation generator originally created for Python
8+
and now maintained as an independent project.
89

910
.. _reStructuredText: https://docutils.sourceforge.io/rst.html
1011
.. _Sphinx: https://www.sphinx-doc.org/
@@ -20,14 +21,14 @@ volunteers are always welcome!
2021
Many thanks go to:
2122

2223
* Fred L. Drake, Jr., the creator of the original Python documentation toolset
23-
and writer of much of the content;
24+
and author of much of the content;
2425
* the `Docutils <https://docutils.sourceforge.io/>`_ project for creating
2526
reStructuredText and the Docutils suite;
2627
* Fredrik Lundh for his Alternative Python Reference project from which Sphinx
2728
got many good ideas.
2829

2930

30-
Contributors to the Python Documentation
31+
Contributors to the Python documentation
3132
----------------------------------------
3233

3334
Many people have contributed to the Python language, the Python standard

Doc/c-api/apiabiversion.rst

Lines changed: 76 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
API and ABI Versioning
77
***********************
88

9+
10+
Build-time version constants
11+
----------------------------
12+
913
CPython exposes its version number in the following macros.
10-
Note that these correspond to the version code is **built** with,
11-
not necessarily the version used at **run time**.
14+
Note that these correspond to the version code is **built** with.
15+
See :c:var:`Py_Version` for the version used at **run time**.
1216

1317
See :ref:`stable` for a discussion of API and ABI stability across versions.
1418

@@ -37,37 +41,83 @@ See :ref:`stable` for a discussion of API and ABI stability across versions.
3741
.. c:macro:: PY_VERSION_HEX
3842
3943
The Python version number encoded in a single integer.
44+
See :c:func:`Py_PACK_FULL_VERSION` for the encoding details.
4045

41-
The underlying version information can be found by treating it as a 32 bit
42-
number in the following manner:
43-
44-
+-------+-------------------------+-------------------------+--------------------------+
45-
| Bytes | Bits (big endian order) | Meaning | Value for ``3.4.1a2`` |
46-
+=======+=========================+=========================+==========================+
47-
| 1 | 1-8 | ``PY_MAJOR_VERSION`` | ``0x03`` |
48-
+-------+-------------------------+-------------------------+--------------------------+
49-
| 2 | 9-16 | ``PY_MINOR_VERSION`` | ``0x04`` |
50-
+-------+-------------------------+-------------------------+--------------------------+
51-
| 3 | 17-24 | ``PY_MICRO_VERSION`` | ``0x01`` |
52-
+-------+-------------------------+-------------------------+--------------------------+
53-
| 4 | 25-28 | ``PY_RELEASE_LEVEL`` | ``0xA`` |
54-
+ +-------------------------+-------------------------+--------------------------+
55-
| | 29-32 | ``PY_RELEASE_SERIAL`` | ``0x2`` |
56-
+-------+-------------------------+-------------------------+--------------------------+
46+
Use this for numeric comparisons, for example,
47+
``#if PY_VERSION_HEX >= ...``.
5748

58-
Thus ``3.4.1a2`` is hexversion ``0x030401a2`` and ``3.10.0`` is
59-
hexversion ``0x030a00f0``.
6049

61-
Use this for numeric comparisons, e.g. ``#if PY_VERSION_HEX >= ...``.
62-
63-
This version is also available via the symbol :c:var:`Py_Version`.
50+
Run-time version
51+
----------------
6452

6553
.. c:var:: const unsigned long Py_Version
6654
67-
The Python runtime version number encoded in a single constant integer, with
68-
the same format as the :c:macro:`PY_VERSION_HEX` macro.
55+
The Python runtime version number encoded in a single constant integer.
56+
See :c:func:`Py_PACK_FULL_VERSION` for the encoding details.
6957
This contains the Python version used at run time.
7058

59+
Use this for numeric comparisons, for example, ``if (Py_Version >= ...)``.
60+
7161
.. versionadded:: 3.11
7262

73-
All the given macros are defined in :source:`Include/patchlevel.h`.
63+
64+
Bit-packing macros
65+
------------------
66+
67+
.. c:function:: uint32_t Py_PACK_FULL_VERSION(int major, int minor, int micro, int release_level, int release_serial)
68+
69+
Return the given version, encoded as a single 32-bit integer with
70+
the following structure:
71+
72+
+------------------+-------+----------------+-----------+--------------------------+
73+
| | No. | | | Example values |
74+
| | of | | +-------------+------------+
75+
| Argument | bits | Bit mask | Bit shift | ``3.4.1a2`` | ``3.10.0`` |
76+
+==================+=======+================+===========+=============+============+
77+
| *major* | 8 | ``0xFF000000`` | 24 | ``0x03`` | ``0x03`` |
78+
+------------------+-------+----------------+-----------+-------------+------------+
79+
| *minor* | 8 | ``0x00FF0000`` | 16 | ``0x04`` | ``0x0A`` |
80+
+------------------+-------+----------------+-----------+-------------+------------+
81+
| *micro* | 8 | ``0x0000FF00`` | 8 | ``0x01`` | ``0x00`` |
82+
+------------------+-------+----------------+-----------+-------------+------------+
83+
| *release_level* | 4 | ``0x000000F0`` | 4 | ``0xA`` | ``0xF`` |
84+
+------------------+-------+----------------+-----------+-------------+------------+
85+
| *release_serial* | 4 | ``0x0000000F`` | 0 | ``0x2`` | ``0x0`` |
86+
+------------------+-------+----------------+-----------+-------------+------------+
87+
88+
For example:
89+
90+
+-------------+------------------------------------+-----------------+
91+
| Version | ``Py_PACK_FULL_VERSION`` arguments | Encoded version |
92+
+=============+====================================+=================+
93+
| ``3.4.1a2`` | ``(3, 4, 1, 0xA, 2)`` | ``0x030401a2`` |
94+
+-------------+------------------------------------+-----------------+
95+
| ``3.10.0`` | ``(3, 10, 0, 0xF, 0)`` | ``0x030a00f0`` |
96+
+-------------+------------------------------------+-----------------+
97+
98+
Out-of range bits in the arguments are ignored.
99+
That is, the macro can be defined as:
100+
101+
.. code-block:: c
102+
103+
#ifndef Py_PACK_FULL_VERSION
104+
#define Py_PACK_FULL_VERSION(X, Y, Z, LEVEL, SERIAL) ( \
105+
(((X) & 0xff) << 24) | \
106+
(((Y) & 0xff) << 16) | \
107+
(((Z) & 0xff) << 8) | \
108+
(((LEVEL) & 0xf) << 4) | \
109+
(((SERIAL) & 0xf) << 0))
110+
#endif
111+
112+
``Py_PACK_FULL_VERSION`` is primarily a macro, intended for use in
113+
``#if`` directives, but it is also available as an exported function.
114+
115+
.. versionadded:: 3.14
116+
117+
.. c:function:: uint32_t Py_PACK_VERSION(int major, int minor)
118+
119+
Equivalent to ``Py_PACK_FULL_VERSION(major, minor, 0, 0, 0)``.
120+
The result does not correspond to any Python release, but is useful
121+
in numeric comparisons.
122+
123+
.. versionadded:: 3.14

0 commit comments

Comments
 (0)