Skip to content

Commit 76c7e0f

Browse files
authored
Merge branch 'main' into complex-realimag-asdouble
2 parents 0e07b65 + 344d3a2 commit 76c7e0f

File tree

620 files changed

+17211
-8077
lines changed

Some content is hidden

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

620 files changed

+17211
-8077
lines changed

.github/workflows/build.yml

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
run-docs: ${{ steps.docs-changes.outputs.run-docs || false }}
4141
run_tests: ${{ steps.check.outputs.run_tests }}
4242
run_hypothesis: ${{ steps.check.outputs.run_hypothesis }}
43+
run_cifuzz: ${{ steps.check.outputs.run_cifuzz }}
4344
config_hash: ${{ steps.config_hash.outputs.hash }}
4445
steps:
4546
- uses: actions/checkout@v4
@@ -76,6 +77,21 @@ jobs:
7677
echo "Run hypothesis tests"
7778
echo "run_hypothesis=true" >> $GITHUB_OUTPUT
7879
fi
80+
81+
# oss-fuzz maintains a configuration for fuzzing the main branch of
82+
# CPython, so CIFuzz should be run only for code that is likely to be
83+
# merged into the main branch; compatibility with older branches may
84+
# be broken.
85+
FUZZ_RELEVANT_FILES='(\.c$|\.h$|\.cpp$|^configure$|^\.github/workflows/build\.yml$|^Modules/_xxtestfuzz)'
86+
if [ "$GITHUB_BASE_REF" = "main" ] && [ "$(git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qE $FUZZ_RELEVANT_FILES; echo $?)" -eq 0 ]; then
87+
# The tests are pretty slow so they are executed only for PRs
88+
# changing relevant files.
89+
echo "Run CIFuzz tests"
90+
echo "run_cifuzz=true" >> $GITHUB_OUTPUT
91+
else
92+
echo "Branch too old for CIFuzz tests; or no C files were changed"
93+
echo "run_cifuzz=false" >> $GITHUB_OUTPUT
94+
fi
7995
- name: Compute hash for config cache key
8096
id: config_hash
8197
run: |
@@ -140,9 +156,6 @@ jobs:
140156
run: make regen-configure
141157
- name: Build CPython
142158
run: |
143-
# Deepfreeze will usually cause global objects to be added or removed,
144-
# so we run it before regen-global-objects gets rum (in regen-all).
145-
make regen-deepfreeze
146159
make -j4 regen-all
147160
make regen-stdlib-module-names
148161
- name: Check for changes
@@ -182,7 +195,7 @@ jobs:
182195
- name: Display build info
183196
run: .\python.bat -m test.pythoninfo
184197
- name: Tests
185-
run: .\PCbuild\rt.bat -p Win32 -d -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
198+
run: .\PCbuild\rt.bat -p Win32 -d -q --fast-ci
186199

187200
build_win_amd64:
188201
name: 'Windows (x64)'
@@ -201,7 +214,7 @@ jobs:
201214
- name: Display build info
202215
run: .\python.bat -m test.pythoninfo
203216
- name: Tests
204-
run: .\PCbuild\rt.bat -p x64 -d -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
217+
run: .\PCbuild\rt.bat -p x64 -d -q --fast-ci
205218

206219
build_win_arm64:
207220
name: 'Windows (arm64)'
@@ -252,7 +265,7 @@ jobs:
252265
- name: Display build info
253266
run: make pythoninfo
254267
- name: Tests
255-
run: make buildbottest TESTOPTS="-j4 -uall,-cpu"
268+
run: make test
256269

257270
build_ubuntu:
258271
name: 'Ubuntu'
@@ -261,7 +274,7 @@ jobs:
261274
needs: check_source
262275
if: needs.check_source.outputs.run_tests == 'true'
263276
env:
264-
OPENSSL_VER: 1.1.1v
277+
OPENSSL_VER: 3.0.11
265278
PYTHONSTRICTEXTENSIONBUILD: 1
266279
steps:
267280
- uses: actions/checkout@v4
@@ -319,7 +332,7 @@ jobs:
319332
run: sudo mount $CPYTHON_RO_SRCDIR -oremount,rw
320333
- name: Tests
321334
working-directory: ${{ env.CPYTHON_BUILDDIR }}
322-
run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
335+
run: xvfb-run make test
323336

324337
build_ubuntu_ssltests:
325338
name: 'Ubuntu SSL tests with OpenSSL'
@@ -330,7 +343,7 @@ jobs:
330343
strategy:
331344
fail-fast: false
332345
matrix:
333-
openssl_ver: [1.1.1v, 3.0.10, 3.1.2]
346+
openssl_ver: [1.1.1w, 3.0.11, 3.1.3]
334347
env:
335348
OPENSSL_VER: ${{ matrix.openssl_ver }}
336349
MULTISSL_DIR: ${{ github.workspace }}/multissl
@@ -382,7 +395,7 @@ jobs:
382395
needs: check_source
383396
if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true'
384397
env:
385-
OPENSSL_VER: 1.1.1v
398+
OPENSSL_VER: 3.0.11
386399
PYTHONSTRICTEXTENSIONBUILD: 1
387400
steps:
388401
- uses: actions/checkout@v4
@@ -491,7 +504,7 @@ jobs:
491504
needs: check_source
492505
if: needs.check_source.outputs.run_tests == 'true'
493506
env:
494-
OPENSSL_VER: 1.1.1v
507+
OPENSSL_VER: 3.0.11
495508
PYTHONSTRICTEXTENSIONBUILD: 1
496509
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
497510
steps:
@@ -535,7 +548,47 @@ jobs:
535548
- name: Display build info
536549
run: make pythoninfo
537550
- name: Tests
538-
run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
551+
run: xvfb-run make test
552+
553+
# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
554+
cifuzz:
555+
name: CIFuzz
556+
runs-on: ubuntu-latest
557+
timeout-minutes: 60
558+
needs: check_source
559+
if: needs.check_source.outputs.run_cifuzz == 'true'
560+
permissions:
561+
security-events: write
562+
strategy:
563+
fail-fast: false
564+
matrix:
565+
sanitizer: [address, undefined, memory]
566+
steps:
567+
- name: Build fuzzers (${{ matrix.sanitizer }})
568+
id: build
569+
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
570+
with:
571+
oss-fuzz-project-name: cpython3
572+
sanitizer: ${{ matrix.sanitizer }}
573+
- name: Run fuzzers (${{ matrix.sanitizer }})
574+
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
575+
with:
576+
fuzz-seconds: 600
577+
oss-fuzz-project-name: cpython3
578+
output-sarif: true
579+
sanitizer: ${{ matrix.sanitizer }}
580+
- name: Upload crash
581+
uses: actions/upload-artifact@v3
582+
if: failure() && steps.build.outcome == 'success'
583+
with:
584+
name: ${{ matrix.sanitizer }}-artifacts
585+
path: ./out/artifacts
586+
- name: Upload SARIF
587+
if: always() && steps.build.outcome == 'success'
588+
uses: github/codeql-action/upload-sarif@v2
589+
with:
590+
sarif_file: cifuzz-sarif/results.sarif
591+
checkout_path: cifuzz-sarif
539592

540593
all-required-green: # This job does nothing and is only used for the branch protection
541594
name: All required checks pass
@@ -553,6 +606,7 @@ jobs:
553606
- build_ubuntu_ssltests
554607
- test_hypothesis
555608
- build_asan
609+
- cifuzz
556610

557611
runs-on: ubuntu-latest
558612

@@ -565,6 +619,7 @@ jobs:
565619
build_ubuntu_ssltests,
566620
build_win32,
567621
build_win_arm64,
622+
cifuzz,
568623
test_hypothesis,
569624
allowed-skips: >-
570625
${{
@@ -588,6 +643,13 @@ jobs:
588643
'
589644
|| ''
590645
}}
646+
${{
647+
!fromJSON(needs.check_source.outputs.run_cifuzz)
648+
&& '
649+
cifuzz,
650+
'
651+
|| ''
652+
}}
591653
${{
592654
!fromJSON(needs.check_source.outputs.run_hypothesis)
593655
&& '

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ permissions:
77

88
env:
99
FORCE_COLOR: 1
10-
RUFF_FORMAT: github
10+
RUFF_OUTPUT_FORMAT: github
1111

1212
concurrency:
1313
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.github/workflows/reusable-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
- name: 'Set up Python'
7575
uses: actions/setup-python@v4
7676
with:
77-
python-version: '3.11' # known to work with Sphinx 3.2
77+
python-version: '3.11' # known to work with Sphinx 4.2
7878
cache: 'pip'
7979
cache-dependency-path: 'Doc/requirements-oldest-sphinx.txt'
8080
- name: 'Install build dependencies'

.pre-commit-config.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.0.288
3+
rev: v0.0.292
44
hooks:
55
- id: ruff
66
name: Run Ruff on Lib/test/
77
args: [--exit-non-zero-on-fix]
88
files: ^Lib/test/
9+
- id: ruff
10+
name: Run Ruff on Argument Clinic
11+
args: [--exit-non-zero-on-fix, --config=Tools/clinic/.ruff.toml]
12+
files: ^Tools/clinic/|Lib/test/test_clinic.py
913

1014
- repo: https://github.com/pre-commit/pre-commit-hooks
1115
rev: v4.4.0
@@ -17,7 +21,16 @@ repos:
1721
types: [python]
1822
exclude: Lib/test/tokenizedata/coding20731.py
1923
- id: trailing-whitespace
20-
types_or: [c, python, rst]
24+
types_or: [c, inc, python, rst]
25+
26+
- repo: local
27+
hooks:
28+
- id: python-file-whitespace
29+
name: "Check Python file whitespace"
30+
entry: 'python Tools/patchcheck/reindent.py --nobackup --newline LF'
31+
language: 'system'
32+
types: [python]
33+
exclude: '^(Lib/test/tokenizedata/|Tools/c-analyzer/cpython/_parser).*$'
2134

2235
- repo: https://github.com/sphinx-contrib/sphinx-lint
2336
rev: v0.6.8
@@ -26,3 +39,8 @@ repos:
2639
args: [--enable=default-role]
2740
files: ^Doc/|^Misc/NEWS.d/next/
2841
types: [rst]
42+
43+
- repo: meta
44+
hooks:
45+
- id: check-hooks-apply
46+
- id: check-useless-excludes

Doc/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
PYTHON = python3
88
VENVDIR = ./venv
99
SPHINXBUILD = PATH=$(VENVDIR)/bin:$$PATH sphinx-build
10-
SPHINXLINT = PATH=$(VENVDIR)/bin:$$PATH sphinx-lint
1110
BLURB = PATH=$(VENVDIR)/bin:$$PATH blurb
1211
JOBS = auto
1312
PAPER =

Doc/c-api/init.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,19 @@ code, or when embedding the Python interpreter:
870870
When the current thread state is ``NULL``, this issues a fatal error (so that
871871
the caller needn't check for ``NULL``).
872872
873+
See also :c:func:`PyThreadState_GetUnchecked`.
874+
875+
876+
.. c:function:: PyThreadState* PyThreadState_GetUnchecked()
877+
878+
Similar to :c:func:`PyThreadState_Get`, but don't kill the process with a
879+
fatal error if it is NULL. The caller is responsible to check if the result
880+
is NULL.
881+
882+
.. versionadded:: 3.13
883+
In Python 3.5 to 3.12, the function was private and known as
884+
``_PyThreadState_UncheckedGet()``.
885+
873886
874887
.. c:function:: PyThreadState* PyThreadState_Swap(PyThreadState *tstate)
875888

Doc/c-api/init_config.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,19 @@ PyConfig
878878
879879
.. versionadded:: 3.12
880880
881+
.. c:member:: int cpu_count
882+
883+
If the value of :c:member:`~PyConfig.cpu_count` is not ``-1`` then it will
884+
override the return values of :func:`os.cpu_count`,
885+
:func:`os.process_cpu_count`, and :func:`multiprocessing.cpu_count`.
886+
887+
Configured by the :samp:`-X cpu_count={n|default}` command line
888+
flag or the :envvar:`PYTHON_CPU_COUNT` environment variable.
889+
890+
Default: ``-1``.
891+
892+
.. versionadded:: 3.13
893+
881894
.. c:member:: int isolated
882895
883896
If greater than ``0``, enable isolated mode:

Doc/c-api/object.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,21 @@ Object Protocol
489489
:c:macro:`Py_TPFLAGS_ITEMS_AT_END` set.
490490
491491
.. versionadded:: 3.12
492+
493+
.. c:function:: int PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg)
494+
495+
Visit the managed dictionary of *obj*.
496+
497+
This function must only be called in a traverse function of the type which
498+
has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set.
499+
500+
.. versionadded:: 3.13
501+
502+
.. c:function:: void PyObject_ClearManagedDict(PyObject *obj)
503+
504+
Clear the managed dictionary of *obj*.
505+
506+
This function must only be called in a traverse function of the type which
507+
has the :c:macro:`Py_TPFLAGS_MANAGED_DICT` flag set.
508+
509+
.. versionadded:: 3.13

Doc/c-api/sys.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,19 +291,24 @@ accessible to C code. They all work with the current interpreter thread's
291291
Raise an auditing event with any active hooks. Return zero for success
292292
and non-zero with an exception set on failure.
293293
294+
The *event* string argument must not be *NULL*.
295+
294296
If any hooks have been added, *format* and other arguments will be used
295297
to construct a tuple to pass. Apart from ``N``, the same format characters
296298
as used in :c:func:`Py_BuildValue` are available. If the built value is not
297-
a tuple, it will be added into a single-element tuple. (The ``N`` format
298-
option consumes a reference, but since there is no way to know whether
299-
arguments to this function will be consumed, using it may cause reference
300-
leaks.)
299+
a tuple, it will be added into a single-element tuple.
300+
301+
The ``N`` format option must not be used. It consumes a reference, but since
302+
there is no way to know whether arguments to this function will be consumed,
303+
using it may cause reference leaks.
301304
302305
Note that ``#`` format characters should always be treated as
303306
:c:type:`Py_ssize_t`, regardless of whether ``PY_SSIZE_T_CLEAN`` was defined.
304307
305308
:func:`sys.audit` performs the same function from Python code.
306309
310+
See also :c:func:`PySys_AuditTuple`.
311+
307312
.. versionadded:: 3.8
308313
309314
.. versionchanged:: 3.8.2
@@ -312,6 +317,14 @@ accessible to C code. They all work with the current interpreter thread's
312317
unavoidable deprecation warning was raised.
313318
314319
320+
.. c:function:: int PySys_AuditTuple(const char *event, PyObject *args)
321+
322+
Similar to :c:func:`PySys_Audit`, but pass arguments as a Python object.
323+
*args* must be a :class:`tuple`. To pass no arguments, *args* can be *NULL*.
324+
325+
.. versionadded:: 3.13
326+
327+
315328
.. c:function:: int PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
316329
317330
Append the callable *hook* to the list of active auditing hooks.

0 commit comments

Comments
 (0)