Skip to content

Commit 291ed52

Browse files
authored
Merge branch 'main' into remove_classmethod_descriptor_chaining
2 parents a7b0830 + 21f068d commit 291ed52

File tree

1,349 files changed

+33187
-19209
lines changed

Some content is hidden

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

1,349 files changed

+33187
-19209
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ indent_style = space
88
[*.{py,c,cpp,h}]
99
indent_size = 4
1010

11+
[*.rst]
12+
indent_size = 3
13+
1114
[*.yml]
1215
indent_size = 2

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ body:
3939
- "3.10"
4040
- "3.11"
4141
- "3.12"
42+
- "3.13"
4243
- "CPython main branch"
4344
validations:
4445
required: true

.github/workflows/build.yml

Lines changed: 65 additions & 0 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: |
@@ -534,6 +550,46 @@ jobs:
534550
- name: Tests
535551
run: xvfb-run make test
536552

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
592+
537593
all-required-green: # This job does nothing and is only used for the branch protection
538594
name: All required checks pass
539595
if: always()
@@ -550,6 +606,7 @@ jobs:
550606
- build_ubuntu_ssltests
551607
- test_hypothesis
552608
- build_asan
609+
- cifuzz
553610

554611
runs-on: ubuntu-latest
555612

@@ -562,6 +619,7 @@ jobs:
562619
build_ubuntu_ssltests,
563620
build_win32,
564621
build_win_arm64,
622+
cifuzz,
565623
test_hypothesis,
566624
allowed-skips: >-
567625
${{
@@ -585,6 +643,13 @@ jobs:
585643
'
586644
|| ''
587645
}}
646+
${{
647+
!fromJSON(needs.check_source.outputs.run_cifuzz)
648+
&& '
649+
cifuzz,
650+
'
651+
|| ''
652+
}}
588653
${{
589654
!fromJSON(needs.check_source.outputs.run_hypothesis)
590655
&& '

.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 }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ gmon.out
4242
.coverage
4343
.mypy_cache/
4444
.pytest_cache/
45+
.ruff_cache/
4546
.DS_Store
4647

4748
*.exe

.pre-commit-config.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.0.292
3+
rev: v0.1.2
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
11-
rev: v4.4.0
15+
rev: v4.5.0
1216
hooks:
1317
- id: check-toml
1418
exclude: ^Lib/test/test_tomllib/
@@ -17,12 +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]
2125

2226
- repo: https://github.com/sphinx-contrib/sphinx-lint
23-
rev: v0.6.8
27+
rev: v0.8.1
2428
hooks:
2529
- id: sphinx-lint
2630
args: [--enable=default-role]
2731
files: ^Doc/|^Misc/NEWS.d/next/
28-
types: [rst]
32+
33+
- repo: meta
34+
hooks:
35+
- id: check-hooks-apply
36+
- 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/arg.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,10 @@ API Functions
416416
.. c:function:: int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], ...)
417417
418418
Parse the parameters of a function that takes both positional and keyword
419-
parameters into local variables. The *keywords* argument is a
420-
``NULL``-terminated array of keyword parameter names. Empty names denote
419+
parameters into local variables.
420+
The *keywords* argument is a ``NULL``-terminated array of keyword parameter
421+
names specified as null-terminated ASCII or UTF-8 encoded C strings.
422+
Empty names denote
421423
:ref:`positional-only parameters <positional-only_parameter>`.
422424
Returns true on success; on failure, it returns false and raises the
423425
appropriate exception.
@@ -426,6 +428,9 @@ API Functions
426428
Added support for :ref:`positional-only parameters
427429
<positional-only_parameter>`.
428430
431+
.. versionchanged:: 3.13
432+
Added support for non-ASCII keyword parameter names.
433+
429434
430435
.. c:function:: int PyArg_VaParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char *keywords[], va_list vargs)
431436

Doc/c-api/call.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ This is a pointer to a function with the following signature:
108108
Doing so will allow callables such as bound methods to make their onward
109109
calls (which include a prepended *self* argument) very efficiently.
110110

111+
.. versionadded:: 3.8
112+
111113
To call an object that implements vectorcall, use a :ref:`call API <capi-call>`
112114
function as with any other callable.
113115
:c:func:`PyObject_Vectorcall` will usually be most efficient.

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

0 commit comments

Comments
 (0)