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

Skip to content

Commit bec7330

Browse files
Merge branch 'main' into sqlite
2 parents 1bdb28f + ecd2f84 commit bec7330

File tree

499 files changed

+27602
-25079
lines changed

Some content is hidden

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

499 files changed

+27602
-25079
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,7 @@ Lib/test/test_configparser.py @jaraco
304304
Doc/reference/ @willingc @AA-Turner
305305

306306
**/*weakref* @kumaraditya303
307+
308+
# Colorize
309+
Lib/_colorize.py @hugovk
310+
Lib/test/test__colorize.py @hugovk

.github/workflows/build.yml

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ concurrency:
1818
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-reusable
1919
cancel-in-progress: true
2020

21+
env:
22+
FORCE_COLOR: 1
23+
2124
jobs:
2225
check_source:
2326
name: Change detection
@@ -509,26 +512,59 @@ jobs:
509512
run: xvfb-run make ci
510513

511514
build_tsan:
512-
name: 'Thread sanitizer'
515+
name: >-
516+
Thread sanitizer
517+
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
513518
needs: check_source
514519
if: needs.check_source.outputs.run_tests == 'true'
520+
strategy:
521+
matrix:
522+
free-threading:
523+
- false
524+
- true
515525
uses: ./.github/workflows/reusable-tsan.yml
516526
with:
517527
config_hash: ${{ needs.check_source.outputs.config_hash }}
518-
options: ./configure --config-cache --with-thread-sanitizer --with-pydebug
519-
suppressions_path: Tools/tsan/supressions.txt
520-
tsan_logs_artifact_name: tsan-logs-default
528+
free-threading: ${{ matrix.free-threading }}
521529

522-
build_tsan_free_threading:
523-
name: 'Thread sanitizer (free-threading)'
530+
cross-build-linux:
531+
name: Cross build Linux
532+
runs-on: ubuntu-latest
524533
needs: check_source
525534
if: needs.check_source.outputs.run_tests == 'true'
526-
uses: ./.github/workflows/reusable-tsan.yml
527-
with:
528-
config_hash: ${{ needs.check_source.outputs.config_hash }}
529-
options: ./configure --config-cache --disable-gil --with-thread-sanitizer --with-pydebug
530-
suppressions_path: Tools/tsan/suppressions_free_threading.txt
531-
tsan_logs_artifact_name: tsan-logs-free-threading
535+
steps:
536+
- uses: actions/checkout@v4
537+
with:
538+
persist-credentials: false
539+
- name: Runner image version
540+
run: echo "IMAGE_VERSION=${ImageVersion}" >> "$GITHUB_ENV"
541+
- name: Restore config.cache
542+
uses: actions/cache@v4
543+
with:
544+
path: config.cache
545+
key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config_hash }}
546+
- name: Register gcc problem matcher
547+
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
548+
- name: Set build dir
549+
run:
550+
# an absolute path outside of the working directoy
551+
echo "BUILD_DIR=$(realpath ${{ github.workspace }}/../build)" >> "$GITHUB_ENV"
552+
- name: Install Dependencies
553+
run: sudo ./.github/workflows/posix-deps-apt.sh
554+
- name: Configure host build
555+
run: ./configure --prefix="$BUILD_DIR/host-python"
556+
- name: Install host Python
557+
run: make -j8 install
558+
- name: Run test subset with host build
559+
run: |
560+
"$BUILD_DIR/host-python/bin/python3" -m test test_sysconfig test_site test_embed
561+
- name: Configure cross build
562+
run: ./configure --prefix="$BUILD_DIR/cross-python" --with-build-python="$BUILD_DIR/host-python/bin/python3"
563+
- name: Install cross Python
564+
run: make -j8 install
565+
- name: Run test subset with host build
566+
run: |
567+
"$BUILD_DIR/cross-python/bin/python3" -m test test_sysconfig test_site test_embed
532568
533569
# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
534570
cifuzz:
@@ -588,7 +624,6 @@ jobs:
588624
- test_hypothesis
589625
- build_asan
590626
- build_tsan
591-
- build_tsan_free_threading
592627
- cifuzz
593628

594629
runs-on: ubuntu-latest
@@ -622,7 +657,6 @@ jobs:
622657
build_windows,
623658
build_asan,
624659
build_tsan,
625-
build_tsan_free_threading,
626660
'
627661
|| ''
628662
}}

.github/workflows/jit.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ on:
1515
required: true
1616
type: string
1717

18+
env:
19+
FORCE_COLOR: 1
20+
1821
jobs:
1922
build_macos:
2023
name: build and test (${{ inputs.os }})

.github/workflows/reusable-tsan.yml

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,20 @@ on:
66
config_hash:
77
required: true
88
type: string
9-
options:
10-
required: true
11-
type: string
12-
suppressions_path:
13-
description: 'A repo relative path to the suppressions file'
14-
required: true
15-
type: string
16-
tsan_logs_artifact_name:
17-
description: 'Name of the TSAN logs artifact. Must be unique for each job.'
18-
required: true
19-
type: string
9+
free-threading:
10+
description: Whether to use free-threaded mode
11+
required: false
12+
type: boolean
13+
default: false
14+
15+
env:
16+
FORCE_COLOR: 1
2017

2118
jobs:
2219
build_tsan_reusable:
2320
name: 'Thread sanitizer'
2421
runs-on: ubuntu-24.04
2522
timeout-minutes: 60
26-
env:
27-
OPTIONS: ${{ inputs.options }}
28-
SUPPRESSIONS_PATH: ${{ inputs.suppressions_path }}
2923
steps:
3024
- uses: actions/checkout@v4
3125
with:
@@ -52,7 +46,11 @@ jobs:
5246
sudo sysctl -w vm.mmap_rnd_bits=28
5347
- name: TSAN Option Setup
5448
run: |
55-
echo "TSAN_OPTIONS=log_path=${GITHUB_WORKSPACE}/tsan_log suppressions=${GITHUB_WORKSPACE}/${SUPPRESSIONS_PATH} handle_segv=0" >> "$GITHUB_ENV"
49+
echo "TSAN_OPTIONS=log_path=${GITHUB_WORKSPACE}/tsan_log suppressions=${GITHUB_WORKSPACE}/Tools/tsan/suppressions${{
50+
fromJSON(inputs.free-threading)
51+
&& '_free_threading'
52+
|| ''
53+
}}.txt handle_segv=0" >> "$GITHUB_ENV"
5654
echo "CC=clang" >> "$GITHUB_ENV"
5755
echo "CXX=clang++" >> "$GITHUB_ENV"
5856
- name: Add ccache to PATH
@@ -64,7 +62,12 @@ jobs:
6462
save: ${{ github.event_name == 'push' }}
6563
max-size: "200M"
6664
- name: Configure CPython
67-
run: "${OPTIONS}"
65+
run: >-
66+
./configure
67+
--config-cache
68+
--with-thread-sanitizer
69+
--with-pydebug
70+
${{ fromJSON(inputs.free-threading) && '--disable-gil' || '' }}
6871
- name: Build CPython
6972
run: make -j4
7073
- name: Display build info
@@ -78,6 +81,11 @@ jobs:
7881
if: always()
7982
uses: actions/upload-artifact@v4
8083
with:
81-
name: ${{ inputs.tsan_logs_artifact_name }}
84+
name: >-
85+
tsan-logs-${{
86+
fromJSON(inputs.free-threading)
87+
&& 'free-threading'
88+
|| 'default'
89+
}}
8290
path: tsan_log.*
8391
if-no-files-found: ignore

.github/workflows/reusable-ubuntu.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ on:
2121
required: true
2222
type: string
2323

24+
env:
25+
FORCE_COLOR: 1
26+
2427
jobs:
2528
build_ubuntu_reusable:
2629
name: build and test (${{ inputs.os }})
2730
timeout-minutes: 60
2831
runs-on: ${{ inputs.os }}
2932
env:
30-
FORCE_COLOR: 1
3133
OPENSSL_VER: 3.0.15
3234
PYTHONSTRICTEXTENSIONBUILD: 1
3335
TERM: linux

.github/workflows/reusable-wasi.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
required: true
88
type: string
99

10+
env:
11+
FORCE_COLOR: 1
12+
1013
jobs:
1114
build_wasi_reusable:
1215
name: 'build and test'

.github/workflows/reusable-windows-msi.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
permissions:
1212
contents: read
1313

14+
env:
15+
FORCE_COLOR: 1
16+
1417
jobs:
1518
build:
1619
name: installer for ${{ inputs.arch }}

.github/workflows/reusable-windows.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ on:
1818
default: false
1919

2020
env:
21+
FORCE_COLOR: 1
2122
IncludeUwp: >-
2223
true
2324
2425
jobs:
2526
build:
26-
name: 'build and test (${{ inputs.arch }})'
27+
name: ${{ inputs.arch == 'arm64' && 'build' || 'build and test' }} (${{ inputs.arch }})
2728
runs-on: ${{ inputs.os }}
2829
timeout-minutes: 60
2930
env:

Android/android-env.sh

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# This script must be sourced with the following variables already set:
2-
: ${ANDROID_HOME:?} # Path to Android SDK
3-
: ${HOST:?} # GNU target triplet
2+
: "${ANDROID_HOME:?}" # Path to Android SDK
3+
: "${HOST:?}" # GNU target triplet
44

55
# You may also override the following:
6-
: ${api_level:=24} # Minimum Android API level the build will run on
7-
: ${PREFIX:-} # Path in which to find required libraries
6+
: "${api_level:=24}" # Minimum Android API level the build will run on
7+
: "${PREFIX:-}" # Path in which to find required libraries
88

99

1010
# Print all messages on stderr so they're visible when running within build-wheel.
@@ -27,20 +27,20 @@ fail() {
2727
ndk_version=27.1.12297006
2828

2929
ndk=$ANDROID_HOME/ndk/$ndk_version
30-
if ! [ -e $ndk ]; then
30+
if ! [ -e "$ndk" ]; then
3131
log "Installing NDK - this may take several minutes"
32-
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "ndk;$ndk_version"
32+
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "ndk;$ndk_version"
3333
fi
3434

35-
if [ $HOST = "arm-linux-androideabi" ]; then
35+
if [ "$HOST" = "arm-linux-androideabi" ]; then
3636
clang_triplet=armv7a-linux-androideabi
3737
else
38-
clang_triplet=$HOST
38+
clang_triplet="$HOST"
3939
fi
4040

4141
# These variables are based on BuildSystemMaintainers.md above, and
4242
# $ndk/build/cmake/android.toolchain.cmake.
43-
toolchain=$(echo $ndk/toolchains/llvm/prebuilt/*)
43+
toolchain=$(echo "$ndk"/toolchains/llvm/prebuilt/*)
4444
export AR="$toolchain/bin/llvm-ar"
4545
export AS="$toolchain/bin/llvm-as"
4646
export CC="$toolchain/bin/${clang_triplet}${api_level}-clang"
@@ -72,12 +72,12 @@ LDFLAGS="$LDFLAGS -lm"
7272

7373
# -mstackrealign is included where necessary in the clang launcher scripts which are
7474
# pointed to by $CC, so we don't need to include it here.
75-
if [ $HOST = "arm-linux-androideabi" ]; then
75+
if [ "$HOST" = "arm-linux-androideabi" ]; then
7676
CFLAGS="$CFLAGS -march=armv7-a -mthumb"
7777
fi
7878

7979
if [ -n "${PREFIX:-}" ]; then
80-
abs_prefix=$(realpath $PREFIX)
80+
abs_prefix="$(realpath "$PREFIX")"
8181
CFLAGS="$CFLAGS -I$abs_prefix/include"
8282
LDFLAGS="$LDFLAGS -L$abs_prefix/lib"
8383

@@ -87,11 +87,13 @@ fi
8787

8888
# When compiling C++, some build systems will combine CFLAGS and CXXFLAGS, and some will
8989
# use CXXFLAGS alone.
90-
export CXXFLAGS=$CFLAGS
90+
export CXXFLAGS="$CFLAGS"
9191

9292
# Use the same variable name as conda-build
93-
if [ $(uname) = "Darwin" ]; then
94-
export CPU_COUNT=$(sysctl -n hw.ncpu)
93+
if [ "$(uname)" = "Darwin" ]; then
94+
CPU_COUNT="$(sysctl -n hw.ncpu)"
95+
export CPU_COUNT
9596
else
96-
export CPU_COUNT=$(nproc)
97+
CPU_COUNT="$(nproc)"
98+
export CPU_COUNT
9799
fi

Doc/c-api/import.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,24 @@ Importing Modules
325325
If Python is initialized multiple times, :c:func:`PyImport_AppendInittab` or
326326
:c:func:`PyImport_ExtendInittab` must be called before each Python
327327
initialization.
328+
329+
330+
.. c:function:: PyObject* PyImport_ImportModuleAttr(PyObject *mod_name, PyObject *attr_name)
331+
332+
Import the module *mod_name* and get its attribute *attr_name*.
333+
334+
Names must be Python :class:`str` objects.
335+
336+
Helper function combining :c:func:`PyImport_Import` and
337+
:c:func:`PyObject_GetAttr`. For example, it can raise :exc:`ImportError` if
338+
the module is not found, and :exc:`AttributeError` if the attribute doesn't
339+
exist.
340+
341+
.. versionadded:: 3.14
342+
343+
.. c:function:: PyObject* PyImport_ImportModuleAttrString(const char *mod_name, const char *attr_name)
344+
345+
Similar to :c:func:`PyImport_ImportModuleAttr`, but names are UTF-8 encoded
346+
strings instead of Python :class:`str` objects.
347+
348+
.. versionadded:: 3.14

Doc/c-api/long.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,6 @@ The :c:type:`PyLongWriter` API can be used to import an integer.
824824
825825
Discard a :c:type:`PyLongWriter` created by :c:func:`PyLongWriter_Create`.
826826
827-
*writer* must not be ``NULL``.
827+
If *writer* is ``NULL``, no operation is performed.
828828
829829
The writer instance and the *digits* array are invalid after the call.

0 commit comments

Comments
 (0)
0